Manual Approval with input

The input step pauses the pipeline and waits for a human to approve before continuing.

Syntaxinput message: 'Deploy to production?', ok: 'Deploy'

The input step pauses the pipeline and asks a person to approve (or reject) before it goes on. This is the classic gate before deploying to production.

What it offers

  • A message shown to the approver.
  • Optional ok button text.
  • Optional submitter restriction — only certain users may approve.
  • Optional parameters the approver can fill in.

Timeouts

Wrap input in a timeout so a forgotten approval does not block an agent forever.

Example

Example · bash
pipeline {
    agent any
    stages {
        stage('Build') {
            steps { sh 'make build' }
        }
        stage('Approval') {
            steps {
                timeout(time: 15, unit: 'MINUTES') {
                    input message: 'Deploy to production?', ok: 'Deploy', submitter: 'release-team'
                }
            }
        }
        stage('Deploy') {
            steps { echo 'Deploying to production...' }
        }
    }
}

When to use it

  • A production deploy stage pauses and asks an approver to click Proceed before any changes reach live servers.
  • A pipeline collects a release notes string from the approver at the input step and passes it to the deployment script.
  • A pipeline times out the input step after 24 hours and aborts automatically to prevent agents being held indefinitely.

More examples

Simple approval gate

Pauses the pipeline until someone clicks Deploy in the Jenkins UI, then continues to the next stage.

Example · groovy
stage('Approve Production Deploy') {
  steps {
    input message: 'Deploy to production?',
          ok: 'Deploy'
  }
}

Input with parameter and submitter

Restricts approval to the release-managers group and captures release notes as a pipeline variable.

Example · groovy
stage('Release Approval') {
  steps {
    script {
      def approval = input(
        message: 'Approve release?',
        submitter: 'release-managers',
        parameters: [string(name: 'NOTES', description: 'Release notes')]
      )
      env.RELEASE_NOTES = approval
    }
  }
}

Input with timeout to prevent hang

Wraps the input step in a stage-level timeout so the pipeline aborts automatically after 4 hours if no one responds.

Example · groovy
stage('Manual Gate') {
  options { timeout(time: 4, unit: 'HOURS') }
  steps {
    input message: 'Ready to deploy?', ok: 'Yes, deploy'
  }
}

Discussion

  • Be the first to comment on this lesson.