Reputation: 73
I created a pipeline that has a stage that should execute only when on develop branch. That stage also needs user input. Why does it get stuck on user input for those steps even if I'm on different branch? When I provide input they get skipped correctly.
stage('Deploy to UAT') {
when {
branch 'develop'
beforeAgent true
}
options {
timeout(time: 5, unit: 'MINUTES')
}
input {
message "Deploy to UAT?"
ok "Yes"
}
steps { echo "deploing!" }
}
Jenkins version with BlueOceas is 1.7.0 · Core 2.121.1 · d7cda7a · 13th July 2018 06:49 PM
Upvotes: 5
Views: 1365
Reputation: 967
I recently faced a similar situation and stumbled over the beforeInput
flag in when()
:
when {
beforeInput true
branch 'develop'
}
In the documentation you can find additional information:
By default, the when condition for a stage will not be evaluated before the input, if one is defined. However, this can be changed by specifying the beforeInput option within the when block. If beforeInput is set to true, the when condition will be evaluated first, and the input will only be entered if the when condition evaluates to true.
Upvotes: 3
Reputation: 56
It's a bug in the Jenkins pipeline. The input
step is evaluated before the when
condition.
Upvotes: 2