I have been wondering for ages why is there no `timeout` option in the `input` step? I am aware you can wrap your input in a `timeout() {}`, but that is just impossible when you are using the `input` as part of the stage like so:

       

      pipeline {
          agent any
          stages {
              stage('Example') {
                  input {
                      message "Should we continue?"
                      ok "Yes, we should."
                      submitter "alice,bob"
                      parameters {
                          string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?')
                      }
                  }
                  steps {
                      echo "Hello, ${PERSON}, nice to meet you."
                  }
              }
          }
      }

       

      (Taken from https://jenkins.io/blog/2018/04/09/whats-in-declarative/#input)

       

      The possible "workaround" to this would be to create an `input` step in a previous stage which is wrapped in a `timeout` step, but in our case this makes things even more complicated and hard to read. 

      Are there any plans to include an `timeout` parameter for the `input` step? Maybe something like this (or better?):

       

      input { 
        message "Should we continue?" 
        ok "Yes, we should." 
        submitter "alice,bob" 
        timeout: [time: 1234, unit: 'MINUTES']
        parameters { 
          string(
            name: 'PERSON', 
            defaultValue: 'Mr Jenkins', 
            description: 'Who should I say hello to?'
          ) 
        }
      }

       

       

          [JENKINS-56259] Allow input timeout parameter

          Steve Todorov added a comment -

          jglick thanks for fixing that! Apologize for the wrong component

          Steve Todorov added a comment - jglick thanks for fixing that! Apologize for the wrong component

          carlspring added a comment -

          Hi jglick

           

          Is there any update on this?

           

          carlspring added a comment - Hi  jglick ,    Is there any update on this?  

          Mark Vinkx added a comment -

          You simply can wrap the input in a timeout 

                  stages {
                      stage('Deploy') {
                          steps {
                                      timeout(time: 5, unit: "MINUTES") {
                                          input message: 'Do you want to approve the deploy?', ok: 'Yes'
                                      }
                                      sh './flakey-deploy.sh'
                           }
                      }
                  }
          

          Mark Vinkx added a comment - You simply can wrap the input in a timeout  stages { stage( 'Deploy' ) { steps { timeout(time: 5, unit: "MINUTES" ) { input message: 'Do you want to approve the deploy?' , ok: 'Yes' } sh './flakey-deploy.sh' } } }

          Jesse Glick added a comment -

          markv this is about input as part of a stage rather than one of its steps, which has different behavior (if I understand correctly) with respect to when an executor is locked.

          Jesse Glick added a comment - markv this is about input as part of a stage rather than one of its steps , which has different behavior (if I understand correctly) with respect to when an executor is locked.

          Steve Todorov added a comment -

          markv Yes, you could wrap the input like that, but unfortunately this means that you will allocate an agent and have it do nothing for 5 minutes. Also the Blue Ocean UI would display this stage as "passed" (green) which will be (and is) confusing, because you never know if the stage has actually passed or it has been skipped/not approved - you will need to specifically go into the stage to check the steps, whereas if you have it as a stage input it would show in the UI as skipped. 

          jglick yes, you've understood me correctly

          Steve Todorov added a comment - markv Yes, you could wrap the input like that, but unfortunately this means that you will allocate an agent and have it do nothing for 5 minutes. Also the Blue Ocean UI would display this stage as "passed" (green) which will be (and is) confusing, because you never know if the stage has actually passed or it has been skipped/not approved - you will need to specifically go into the stage to check the steps, whereas if you have it as a stage input it would show in the UI as skipped.  jglick yes, you've understood me correctly

          Hi, has there been any other movement on this particular functionality?

          I've been looking into using pipeline as code to automate deployments and use the steps in stages approach to manage the different elements of the CI process. Having the ability to specify a timeout directly on the input option would be perfect as it appears the stage method does not accept timeout as a valid nested parameter.

          Jordan Cockles added a comment - Hi, has there been any other movement on this particular functionality? I've been looking into using pipeline as code to automate deployments and use the steps in stages approach to manage the different elements of the CI process. Having the ability to specify a timeout directly on the input option would be perfect as it appears the stage method does not accept timeout as a valid nested parameter.

          Hi All,

          Have we tried using options timeout within the stage ?

          https://www.jenkins.io/doc/book/pipeline/syntax/#options

          Currently testing it, but I feel that would help at least while the attribute is added into the directive.

          pipeline {
              agent any
              stages {
                  stage('Example') {
                      options {
                          timeout(time: 1, unit: 'HOURS') 
                      }
                      input{...}
                      steps {
                          echo 'Hello World'
                      }
                  }
              }
          }
          

          Ricardo Chiriboga added a comment - Hi All, Have we tried using options timeout within the stage ? https://www.jenkins.io/doc/book/pipeline/syntax/#options Currently testing it, but I feel that would help at least while the attribute is added into the directive. pipeline { agent any stages { stage( 'Example' ) { options { timeout(time: 1, unit: 'HOURS' ) } input{...} steps { echo 'Hello World' } } } }

          Steve Todorov added a comment -

          rachirib thank you for your suggestion. At a first glance this sounds logical, but the `timeout` option is actually going to set the timeout for the ENTIRE pipeline, not just the stage.  Therefore the remaining pipeline might fail depending on the configured timeout setting and the build time for the next stages.

          The example below demonstrates the issue.

          pipeline {
              agent none
              stages {
                  stage('Example1') {
                      agent {
                          // agent allocation takes about 30-60 seconds
                          label 'alpine-jdk8-mvn3.6'
                      }
                      options {
                          timeout(time: 1, unit: 'MINUTES') 
                      }
                      input {
                          message "Should we continue?"
                          ok "Yes, we should."
                          submitter "alice,bob"
                          parameters {
                              string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?')
                          }
                      }
                      steps {
                          sh 'sleep 5'
                      }
                  }        
                  stage('Example2') {
                      agent {
                          // agent allocation takes about 30-60 seconds
                          label 'alpine-jdk8-mvn3.6'
                      }
                      options {
                          timeout(time: 1, unit: 'MINUTES') 
                      }
                      input {
                          message "Should we continue?"
                          ok "Yes, we should."
                          submitter "alice,bob"
                          parameters {
                              string(name: 'PERSON', defaultValue: 'Mr Jenkins', description: 'Who should I say hello to?')
                          }
                      }
                      steps {
                          sh 'sleep 5'
                      }
                  }
              }
          }
          

           

          And here is the result - the pipeline is cancelled prematurely during the `Example 1` stage (before it has even completed)

           

           

           

          Steve Todorov added a comment - rachirib  thank you for your suggestion. At a first glance this sounds logical, but the `timeout` option is actually going to set the timeout for the ENTIRE pipeline, not just the stage.  Therefore the remaining pipeline might fail depending on the configured timeout setting and the build time for the next stages. The example below demonstrates the issue. pipeline { agent none stages { stage( 'Example1' ) { agent { // agent allocation takes about 30-60 seconds label 'alpine-jdk8-mvn3.6' } options { timeout(time: 1, unit: 'MINUTES' ) } input { message "Should we continue ?" ok "Yes, we should." submitter "alice,bob" parameters { string(name: 'PERSON' , defaultValue: 'Mr Jenkins' , description: 'Who should I say hello to?' ) } } steps { sh 'sleep 5' } } stage( 'Example2' ) { agent { // agent allocation takes about 30-60 seconds label 'alpine-jdk8-mvn3.6' } options { timeout(time: 1, unit: 'MINUTES' ) } input { message "Should we continue ?" ok "Yes, we should." submitter "alice,bob" parameters { string(name: 'PERSON' , defaultValue: 'Mr Jenkins' , description: 'Who should I say hello to?' ) } } steps { sh 'sleep 5' } } } }   And here is the result - the pipeline is cancelled prematurely during the `Example 1` stage (before it has even completed)      

          Pay Bas added a comment -

          Assuming the steps within the stage actually sent output to the console, you can work around this by using:

          timeout(time: 15, unit: 'MINUTES', activity: true) {

          This way you can let the timeout pass when stuck at user input, but not have the stage fail when the input is given at 14:59.

          Pay Bas added a comment - Assuming the steps within the stage actually sent output to the console, you can work around this by using: timeout( time : 15 , unit : 'MINUTES' , activity : true ) { This way you can let the timeout pass when stuck at user input, but not have the stage fail when the input is given at 14:59.

          Steve Todorov added a comment - - edited

          paybas what you propose doesn't work. If you try the same pipeline as the one I posted above you will get the following output:

          23:05:07.395  Timeout set to expire after 1 min 0 sec without activity
          23:05:07.395  [Pipeline] {
          23:05:07.403  [Pipeline] input
          23:05:07.409  Input requested
          23:06:37.411  Cancelling nested steps due to timeout
          23:06:37.421  [Pipeline] }
          23:06:37.425  [Pipeline] // timeout
          23:06:37.428  [Pipeline] }
          23:06:37.431  [Pipeline] // stage
          23:06:37.435  [Pipeline] End of Pipeline
          23:06:37.444  Rejected by System User
          23:06:37.606  Finished: ABORTED
          
          --- this shouldn't have aborted - it should have gotten to the `sh 'sleep 5'` step.

          Which is essentially the same issue but with a different error message at the end.

          The only working solution is to have a `try/catch` script where you have the `timeout` part instead of doing it at a stage level.
          That usually will allocate an agent and usually creates a lot of noise in the pipeline.

           

          Steve Todorov added a comment - - edited paybas  what you propose doesn't work. If you try the same pipeline as the one I posted above you will get the following output: 23:05:07.395 Timeout set to expire after 1 min 0 sec without activity 23:05:07.395 [Pipeline] { 23:05:07.403 [Pipeline] input 23:05:07.409 Input requested 23:06:37.411 Cancelling nested steps due to timeout 23:06:37.421 [Pipeline] } 23:06:37.425 [Pipeline] // timeout 23:06:37.428 [Pipeline] } 23:06:37.431 [Pipeline] // stage 23:06:37.435 [Pipeline] End of Pipeline 23:06:37.444 Rejected by System User 23:06:37.606 Finished: ABORTED --- this shouldn 't have aborted - it should have gotten to the `sh ' sleep 5'` step. Which is essentially the same issue but with a different error message at the end. The only working solution is to have a `try/catch` script where you have the `timeout` part instead of doing it at a stage level. That usually will allocate an agent and usually creates a lot of noise in the pipeline.  

            Unassigned Unassigned
            stodorov Steve Todorov
            Votes:
            3 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated: