Reputation: 2329
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
Upvotes: 8
Views: 26430
Reputation: 519
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:
Upvotes: 1
Reputation: 29
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
Upvotes: 0
Reputation: 2329
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
Upvotes: 17