Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-36235

Add optional 'timeout' parameter to 'input' step

      An optional 'timeout' parameter for the 'input' pipeline step would be very nice. In case of no response within specified amount of time, the build would then fail. Or maybe even make that selectable: fail or continue.

          [JENKINS-36235] Add optional 'timeout' parameter to 'input' step

          Joost created issue -
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 172928 ] New: JNJira + In-Review [ 184832 ]

          Harry Mallon added a comment -

          I have been trying to emulate the 'continue' mode in pipeline for a while. This is useful to us as I want to use a multibranch pipeline and want it to provide both user-started release builds and user or auto started testing builds. The best way to emulate this seems to be to give a user choice and fall through to default options (testing) on timeout. What follows is my current attempt and it doesn't work as I cannot tell the difference between a timeout and user pressed Abort.

          try {
              timeout(1) {
                  input message: 'Do you want to release this build?',
                        parameters: [[$class: 'BooleanParameterDefinition',
                                      defaultValue: false,
                                      description: 'Ticking this box will do a release',
                                      name: 'Release']]
              }
          } catch (err) {
              def hi = err.getCauses()
              echo "Exception thrown:\n ${hi}"
          
              echo err.getLocalizedMessage()
              echo err.getCause()
              echo err.toString()
              echo err.getClass().getName()
          }
          

          What I am saying is this seems to be a major missing part of pipeline for me, and is blocking me moving from the old style builds.

          Harry Mallon added a comment - I have been trying to emulate the 'continue' mode in pipeline for a while. This is useful to us as I want to use a multibranch pipeline and want it to provide both user-started release builds and user or auto started testing builds. The best way to emulate this seems to be to give a user choice and fall through to default options (testing) on timeout. What follows is my current attempt and it doesn't work as I cannot tell the difference between a timeout and user pressed Abort. try { timeout(1) { input message: 'Do you want to release this build?', parameters: [[$class: 'BooleanParameterDefinition', defaultValue: false, description: 'Ticking this box will do a release', name: 'Release']] } } catch (err) { def hi = err.getCauses() echo "Exception thrown:\n ${hi}" echo err.getLocalizedMessage() echo err.getCause() echo err.toString() echo err.getClass().getName() } What I am saying is this seems to be a major missing part of pipeline for me, and is blocking me moving from the old style builds.
          Dan Alvizu made changes -
          Component/s New: workflow-plugin [ 18820 ]
          Component/s Original: build-pipeline-plugin [ 15962 ]

          Jesse Glick added a comment -

          Do not plan to accept the original RFE; should wrap with the timeout step. What harryjenkins was looking for is err.causes, which may be ExceededTimeout, Rejection, or something else like UserInterruption. Currently this is not accessible from a sandboxed script, which is a problem.

          Jesse Glick added a comment - Do not plan to accept the original RFE; should wrap with the timeout step. What harryjenkins was looking for is err.causes , which may be ExceededTimeout , Rejection , or something else like UserInterruption . Currently this is not accessible from a sandboxed script, which is a problem.

          Harry Mallon added a comment -

          jglick: err.causes returns a similar output to err.getCauses(). Both return org.jenkinsci.plugins.workflow.support.steps.input.Rejection@53ed4813 for timeout and abort. I have never seen an Exceeded Timeout cause.

          Harry Mallon added a comment - jglick : err.causes returns a similar output to err.getCauses(). Both return org.jenkinsci.plugins.workflow.support.steps.input.Rejection@53ed4813 for timeout and abort. I have never seen an Exceeded Timeout cause.

          Joost added a comment -

          Wrapping a timeout block around the input step works for me. Thanks!

          Joost added a comment - Wrapping a timeout block around the input step works for me. Thanks!

          Jason Miller added a comment -

          jrkoiter: Does this still work for you? I'm unable to get it working on my instance, using 2.7.2 and the latest pipeline plugins:

          timeout(5) {
            input "waiting..."
          }
          

          The timeout block doesn't seem to work - it just hangs on the input step indefinitely until it's either approved or aborted, just as if it weren't in a timeout block at all.
          If I remove the input step, the timeout works as expected, so it seems like timeout isn't being allowed to abort the input step correctly.

          Jason Miller added a comment - jrkoiter : Does this still work for you? I'm unable to get it working on my instance, using 2.7.2 and the latest pipeline plugins: timeout(5) { input "waiting..." } The timeout block doesn't seem to work - it just hangs on the input step indefinitely until it's either approved or aborted, just as if it weren't in a timeout block at all. If I remove the input step, the timeout works as expected, so it seems like timeout isn't being allowed to abort the input step correctly.

          Joost added a comment - - edited

          The documentation doesn't say what the default unit is. This is working for me:

          node {
              timeout(time: 10, unit: 'SECONDS') {
              input "waiting..."
              }
          }
          

          Joost added a comment - - edited The documentation doesn't say what the default unit is. This is working for me: node { timeout(time: 10, unit: 'SECONDS' ) { input "waiting..." } }
          Andrew Bayer made changes -
          Component/s New: pipeline-general [ 21692 ]

            Unassigned Unassigned
            jrkoiter Joost
            Votes:
            6 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved: