| Scenario I have two pipeline jobs 'Parent' and 'Child' where 'Child' is parameterized and triggered (fire+forget) from 'Parent' multiple times. The total amount of 'Child' jobs triggered from 'Parent' are variable and depend on external parameters.
// Parent.jenkinsfile
pipeline {
agent any
stages {
stage('Trigger Child') {
steps {
script {
for(int i = 0; i < 3; ++i) {
build(
job: 'Child',
parameters: [
string(name: 'alpha', value: 'test'),
string(name: 'beta', value: "${i}")
],
wait: false,
propagate: false)
}
}
}
}
}
}
// Child.jenkinsfile
pipeline {
agent any
parameters {
string(name: 'alpha', description: '', trim: true)
string(name: 'beta', description: '', trim: true)
}
stages {
stage('Hello') {
steps {
buildName "${params.alpha} ${params.beta}"
}
}
}
}
Observed Behaviour From any run of 'Parent', 'Child' is getting triggered for each set of parameter values AND one additional time with all parameters set to empty values (or their defaults). In the example above, 'Child' is triggered with the following values:
- alpha="", beta="null" <--
should not be there
- alpha="test", beta="0"
- alpha="test", beta="1"
- alpha="test", beta="2"
Import Note This spurious job without parameter values is not being triggered when 'Parent' waits for the 'Child' to finish, i.e. if I set wait=true in the build step of 'Parent'. |