This works
steps.build "Job Name"
This doesn't work
steps.build "Job Name -p ParamKey1=ParamValue1 -p ParamKey2=ParamValue2"
I also tried this but no luck
steps.build "Job Name", parameters:[string(name: "Key1", value:"Value1")]
Any help would be appreciated.
CodePudding user response:
This is my example on passing parameters to the child job:
stage('Deploy PROD') {
steps {
build job: 'PROD/Great-Project-Prod',
propagate: true,
wait: true,
parameters: [
//static parameter
string(name: 'environment', value: 'prod'),
//parameter from a function defined on top of the file
string(name: 'projectVersion', value: getVersion()),
//parameter comming from UI defined parameters
string(name: 'envFileId', value: params.envFileId)
]
}
}
CodePudding user response:
Your code accesses steps through the steps
object: steps.build
. The string
method used in the parameters
block has the same visibility as build
. It means you have to use the steps
object to access it:
steps.build "Job Name", parameters: [
steps.string(name: "Key1", value:"Value1")
]