问题
There is any way to trigger a pipeline job from another pipeline with parameters, i already tried
build job: '/myjob', parameters: [string(name: 'param1', value:'val1')], wait: false
also tried
build job: 'myjob', parameters: [string(name: 'param1', value:'val1')], wait: false
and
build job: 'myjob', parameters: [[$class: 'StringParameterValue', name: 'param1', value: 'val1']], wait: false
with no luck, it says:
Item type does not support parameters
回答1:
Since the subjob was another multibranch pipeline project i needed to specify the branch i wanted to run so with
build job: 'myjob/master', parameters: [string(name: 'param1', value:'val1')], wait: false
it now works
回答2:
Depending on your Jenkins job / pipeline structure, you should prefix the job with "../" e.g.:
build job: '../myjob/master', parameters: [string(name: 'param1', value:'val1')], wait: false
回答3:
The below worked for me in order to pass parameters "test_1" and "test_2" from pipeline "master" to pipeline "sub-1"
In the master pipeline
build job: 'sub-1', parameters: [[$class: 'StringParameterValue', name: 'test_1', value: 'nameValue'], [$class: 'StringParameterValue', name: 'test_2', value: 'valueValue']], wait: true
In the sub pipeline "sub-1" use by referencing the "params" variable
node {
echo params.test_1
echo params.test_2
}
Reference:
https://support.cloudbees.com/hc/en-us/articles/221400287-How-to-pass-parameter-to-downstream-job-in-Pipeline-job-
来源:https://stackoverflow.com/questions/48007810/call-parameterized-jenkins-pipeline-from-another-pipeline