I did a kind of similar but not equally implementation. The important bit is to try/catch and ensure the last true/false command is in the right logic, please read the below:
My use case was to run a certain Integration Test, then if it failed for whatever reason, prompt to the user whether to rerun them again with a certain timeout to avoid infinite waits. stage('TestCase') { steps { script { def filter = 'all' waitUntil { def bRun = build job: 'jobX', propagate: false // To avoid failfast/propagate errors if (bRun.getRawBuild().result.isWorseOrEqualTo(hudson.model.Result.FAILURE)) { def userInput = true def didTimeout = false def inputValue try { // Timeout in case to avoid running this forever timeout(time: 60, unit: 'SECONDS') { inputValue = input( id: 'userInput', message: 'jobX failed let\'s rerun it?', parameters: [ [$class: 'BooleanParameterDefinition', defaultValue: true, description: '', name: 'Please confirm you agree with this'] ]) } } catch(err) { // timeout reached or input false echo err.toString() def user = err.getCauses()[0].getUser() if('SYSTEM' == user.toString()) { // SYSTEM means timeout. didTimeout = true } else { userInput = false echo "Aborted by: [${user}]" } } if (didTimeout) { echo "no input was received before timeout" false // false will cause infinite loops but it's a way to keep retrying, otherwise use true and will exit the loop } else if (userInput == true) { echo "this was successful" false // if user answered then iterate through the loop again } else { echo "this was not successful" currentBuild.result = 'ABORTED' true // if user aborted the input then exit the loop } } else { currentBuild.result = 'SUCCESS' true // if build finished successfully as expected then exit the loop } } } } } The above snippet was based on the below how-to: - https://support.cloudbees.com/hc/en-us/articles/226554067-Pipeline-How-to-add-an-input-step-with-timeout-that-continues-if-timeout-is-reached-using-a-default-value I hope it helps -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/dc49bafb-5772-4f03-9ff3-81bb465a8953%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.