i want restrict downstream jenkins job run on specific machine using parameter passed in upstream job. upstream job creates properties file, 1 of properties indicating machine should run on (machine_to_run=linux123 in test.properties).
this file properties passed downstream job using post-build action: trigger parameterized build on other projects. here specify parameters properties file: $workspace/test.properties
i have verified downstream job indeed receive , process file. machine_to_run=linux123 listed in environment variables.
how use env variable restrict job can run. i've tried setting "restrict project can run" ${machine_to_run}, no luck.
anyone have experience doing this?
update: here how implemented this.
download https://wiki.jenkins-ci.org/display/jenkins/groovy+label+assignment+plugin
build parameters bound plugin. if pass cloud id or node job, instance machine_to_run.
the plugin let write groovy script let return want job run.
return machine_to_run;
just implemented alike in morning nodelabel parameter plugin. so, "parametrize" downstream job parameter of "label" type (available after installed plugin mentioned above) , provide value parameter whatever source have (test.properties file in case).
also not have deal "restrict project can run" setting anymore downstream job.
for example, lets have 2 jobs "build" , "test" in jenkins following definitions (using groovy-alike pseudo-code):
[test] parameters: { targetnode: typeof(label), defaultvalue: '' } [build] parameters: {} set-env-variables: { from: './test.properties' } // or way set env vars trace-env-variable: { variable: $machine_to_run } // linux123 post-build: { trigger: { job: "test", parameters: { targetnode: $machine_to_run } } }
that pretty need desired behavior.
Comments
Post a Comment