This is kind of a follow up of already answered question Jenkins pipeline pass all parameters down to downstream jobs : I want to pass all parameters to a downstream job and additionally want to modify one of the parameters as well as add another parameter.
Asked
Active
Viewed 1,418 times
1 Answers
1
after some playing around I got it working like this (although I guess it's not very sophisticated):
newparams=[ string(name: 'PARA1', value: '17'),
string(name: 'PARA2', value: 'true'), ]
def myparams = currentBuild.rawBuild.getAction(ParametersAction).getParameters()
myparams.each{
if (it.name!='PARA1') // don't copy PARA1 from myparams
newparams+=it // add all others
}
buildresult= build job: jobname, propagate: false, parameters: newparams
...so it doesn't simply forward all parameters from getParameters() but copies them to "newparams" one by one. That's where I have the possibility to do some manipulations to the list.
I use it for string parameters only - didn't test with others...

Roman
- 707
- 8
- 16
-
Did this work if i have separate jenkinsfile for each pipeline build? – salsinga Aug 06 '18 at 09:57
-
@saslinga: I didn't try with Jenkinsfile, but I don't see a reason why it shouldn't work. It manipulates the parameters of the newly started build. – Roman Aug 20 '18 at 12:51