How does the declarative `input` directive work?
IntermediateConceptDeclarative pipeline syntax
Answer
A stage-level input pauses before the stage runs and asks a user to proceed or abort. submitter restricts who can approve (users or groups, comma-separated), and parameters collects values that become environment variables in the stage.
stage('Deploy prod') {
options { timeout(time: 4, unit: 'HOURS') }
input {
message 'Promote to production?'
ok 'Deploy'
submitter 'release-managers,alice'
submitterParameter 'APPROVER'
parameters { string(name: 'CHANGE_ID', description: 'Change ticket') }
}
steps { sh './deploy.sh prod "$CHANGE_ID"'; echo "Approved by ${APPROVER}" }
}
More on Declarative pipeline syntax
What is the minimum valid declarative pipeline?BeginnerWhat agent types exist in declarative pipelines?IntermediateWhen do you use `agent none` at the top level?IntermediateHow do nested sequential stages work and why are they useful?IntermediateList the `post` conditions and when each fires.IntermediateWhat are the most useful `when` conditions?Intermediate