title: Jenkins input on declarative pipeline
body: <p>may I ask if it is do-able if I can get the user input and run a script based on what was chosen by the user? the logic whould be</p>
  
  <blockquote>
    <p>IF User choose <strong>Proceed</strong> THEN run a script (in my case promote or Blue/Green deployment)
    IF User choose <strong>Abort</strong> THEN don't terminate the jenkins job, run a script (in my case rollback)</p>
  </blockquote>
  
  <p>This is the script I'm using however I have no idea how to apply after validate stage</p>
  
  <pre><code>  pipeline {
    agent any
  
    stages {
      stage('Deploy') {
        steps {
          sh """#!/bin/bash +x
            echo "performing sts assume role"
            //SCRIPT-HERE//        
            echo "performing ansible deploy"
            //SCRIPT-HERE//  
          """
        }
      }
      stage('validate') {
          steps {
  
              timeout(30) {
                  script {
                      input(message: 'Please validate, this job will automatically ABORTED after 30 minutes even if no user input provided', ok: 'Proceed')
                  }
              }
          }
      }
    }
  
  }
  </code></pre>
  
  <p>One more issue I'm seeing is, although this pipeline script is running, The Proceed / Abort is not clickable on the jenkins job Console output, is it a bug? I'm referring to the image shown below</p>
  
  <p><a href="https://i.stack.imgur.com/IIh3h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IIh3h.png" alt="enter image description here"></a></p>
  
  <p>I was able to add nandilov's suggestion however it seems that the logic is still not applying, please advise on what is missed here</p>
  
  <pre><code>pipeline {
    agent any
  
    stages {
      stage('Deploy') {
        steps {
          sh """#!/bin/bash +x
            echo "performing sts assume role"
  
            echo "performing ansible deploy"
  
          """
        }
      }
      stage('validate') {
          steps {
            script {
              env.flagError = "false"
                try {
                input(message: 'Please validate, this job will automatically ABORTED after 30 minutes even if no user input provided', ok: 'Proceed')
  
                }catch(e){
                  println "input aborted or timeout expired, will try to rollback."
                  env.flagError = "true"        
                }
            }
          }
      }
  
      stage("If user selects Proceed"){
          when{
              expression { env.inputValue == "value1" }
          }
          steps{
              sh """#!/bin/bash +x
                echo "User selected proceed"
              """
          }
      }
  
      stage("rollback if flag error true"){
          when{
              expression { env.inputValue == "value2" }
          }
          steps{
              sh """#!/bin/bash +x
                echo "User selected Abort"
              """
          }
      }
  
    }
  
  }
  </code></pre>
  
  <p>from the pipeline view it never triggered either one of the last two stages when choosing "Abort" or "Proceed"</p>
  
  <p><a href="https://i.stack.imgur.com/5h8Db.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5h8Db.png" alt="enter image description here"></a></p>
  
  <p>These are the logs when choosing Abort or Proceed</p>
  
  <p><strong>ABORT</strong></p>
  
  <pre><code>Running in Durability level: MAX_SURVIVABILITY
  [Pipeline] Start of Pipeline
  [Pipeline] node
  Running on Jenkins in /var/lib/jenkins/workspace/test-job-lagot
  [Pipeline] {
  [Pipeline] stage
  [Pipeline] { (Deploy)
  [Pipeline] sh
  performing sts assume role
  performing ansible deploy
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] stage
  [Pipeline] { (validate)
  [Pipeline] script
  [Pipeline] {
  [Pipeline] input
  Please validate, this job will automatically ABORTED after 30 minutes even if no user input provided
  Proceed or Abort
  [Pipeline] echo
  input aborted or timeout expired, will try to rollback.
  [Pipeline] }
  [Pipeline] // script
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] stage
  [Pipeline] { (If user selects Proceed)
  Stage "If user selects Proceed" skipped due to when conditional
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] stage
  [Pipeline] { (rollback if flag error true)
  Stage "rollback if flag error true" skipped due to when conditional
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] }
  [Pipeline] // node
  [Pipeline] End of Pipeline
  Finished: SUCCESS
  </code></pre>
  
  <p><strong>PROCEED</strong></p>
  
  <pre><code>Started by user lagot
  Running in Durability level: MAX_SURVIVABILITY
  [Pipeline] Start of Pipeline
  [Pipeline] node
  Running on Jenkins in /var/lib/jenkins/workspace/test-job-lagot
  [Pipeline] {
  [Pipeline] stage
  [Pipeline] { (Deploy)
  [Pipeline] sh
  performing sts assume role
  performing ansible deploy
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] stage
  [Pipeline] { (validate)
  [Pipeline] script
  [Pipeline] {
  [Pipeline] input
  Please validate, this job will automatically ABORTED after 30 minutes even if no user input provided
  Proceed or Abort
  Approved by lagot
  [Pipeline] }
  [Pipeline] // script
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] stage
  [Pipeline] { (If user selects Proceed)
  Stage "If user selects Proceed" skipped due to when conditional
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] stage
  [Pipeline] { (rollback if flag error true)
  Stage "rollback if flag error true" skipped due to when conditional
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] }
  [Pipeline] // node
  [Pipeline] End of Pipeline
  Finished: SUCCESS
  </code></pre>