Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins pipeline pass all but manipulated parameters to downstream

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.

like image 990
Roman Avatar asked Jan 30 '26 20:01

Roman


1 Answers

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...

like image 69
Roman Avatar answered Feb 01 '26 16:02

Roman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!