Recently have received a requirement in Jenkins Pipeline deployment with User Input parameters either Yes or No. This option should be ask before start the stages in the Pipeline deployment . This will be used for production release.

This post will walk through steps below, how do we add that option, It would be helps which someone click on the "Build Now" button unfortunately the production deployment started and may face some problem. To prevent this problem we have an option in the Jenkins Groovy pipeline script.

Just add the script code below on the top of the Pipeline starts,

script {
// Define your  user input variable here

  def USER_INPUT = input (message: 'Do you need to Deploy the application to PROD environment,  by default No, Select "YES" Option to proceed,', 
        parameters: [
            [$class: 'ChoiceParameterDefinition',
            choices: [ 'NO', 'YES'].join('\n'),
            name: 'Choose an Option:',
            description: 'Menu - Select box option']
          echo "The answer is: ${USER_INPUT}"
          if( "${USER_INPUT}" == "YES" ) {
          echo "Start the deployment to PRODUCTION environment"
      else {
          echo "exits"
          sh 'exit 0'

pipeline {