jenkinsci / jenkinsci/parameterized-trigger-plugin
[JENKINS-60511] parameterized project triggered with empty parameters from pipeline's for loop
- Dominant language
- Java
- Stars
- 77
- Forks
- 174
- Avg merge
- 22h 27m
- Merged PRs (30d)
- 1
Description
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'.
---
Originally reported by tklatt, imported from: parameterized project triggered with empty parameters from pipeline's for loop
Raw content of original issue
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'.
environment
```
Jenkins 2.190.3 (as Docker container)
Parameterized Trigger plugin 2.36
Pipeline: Build Step 2.10
```
Contributor guide
Assessment
This issue has not been assessed yet.