Roman
Roman

Reputation: 857

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.

Upvotes: 3

Views: 1481

Answers (1)

Roman
Roman

Reputation: 857

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

Upvotes: 1

Related Questions