Interview Prep/Jenkins/Declarative pipeline syntax

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}" }
}
All Jenkins questions Roadmap: Jenkins

More on Declarative pipeline syntax