pipeline {
agent none // no executor is blocked
stages {
stage('Production Deploy') {
when {
branch 'master'// beforeInput: true }
input {
message 'Deploy to Production?'// For this input can be waited several days
}
agent any // From here on for executing the steps an executor is needed
steps {
echo 'Deploying to Production ... '
}
}
}
}
Currently, when using the "stage-level" input (here: [https://jenkins.io/doc/book/pipeline/syntax/#input)] the when condition of the stage is evaluated after the input is gathered. We should add an option so the when condition is evaluated before the input is gathered. Something like:
Just a warning, the beforeInput is not documented in the article nor in the snippet generator. I just faced this and the only solution is in Torsten's comment.