Search code examples
groovyjenkins-pipelinejenkins-job-dsl

How to add additional properties to "readProperties file"?


How to inject key=value pair to properties read using readProperties from file?

...
props = readProperties file: "$parametersFile"
fileParams = props.collect { string(name: it.key, value: it.value) }
build job: "anotherjobName", parameters: fileParams // good, passes parameters read from $parametersFile
fileParams.inject(["EXTRA_PARAM=xparam_value"]) // Is there a way to inject the additional parameter to fileParams, something like this?
build job: "yetAnotherjobName", parameters: fileParams


Solution

  • I could do it as below:

    xParam = [ $class: 'StringParameterValue','name': 'EXTRA_PARAM', 'value': "xparam_value" ]
    build job: "yetAnotherjobName", parameters: fileParams + xParam