Pipeline - How to add an input step, that continues if aborted, using value


How do I add an input step, that continues if aborted, using a value, in a Pipeline job?


  • Jenkins
  • CloudBees Jenkins Enterprise
  • Pipeline plugin


You can use a try catch block to achieve this.

The following asks for input. An if statement checking the input result (userInput) is used to determine what to do next:

def userInput
try {
    userInput = input(
        id: 'Proceed1', message: 'Was this successful?', parameters: [
        [$class: 'BooleanParameterDefinition', defaultValue: true, description: '', name: 'Please confirm you agree with this']
} catch(err) { // input false
    def user = err.getCauses()[0].getUser()
    userInput = false
    echo "Aborted by: [${user}]"

node {
    if (userInput == true) {
        // do something
        echo "this was successful"
    } else {
        // do something else
        echo "this was not successful"
        currentBuild.result = 'FAILURE'


Have more questions? Submit a request


  • 0
    Paolo Brocco

    Hi, I tried your example, but it fails when calling the err.getCauses() method:

    org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use method org.jenkinsci.plugins.workflow.steps.FlowInterruptedException getCauses

    After some time searching online I finally found that there is a UI in jenkins to approve scripts security, at this url: JENKINS_URL/scriptApproval/

    Edited by Paolo Brocco
  • 0
    Sergio Sacristán


    I have the "RejectedAccessException" but I don't have any pending approval.

    I'm executing the pipeline using Jenkinsfile.


    Thank you!

  • 0
    Emilio Escobar Reyero

    Hello Sergio,

    can you please add also the message after "org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException:" ? Thanks

  • 0
    Carlos Rodriguez Lopez

    Paolo Brocco, Sergio Sacristán: Can you provide us the Jenkins + Plugin versions Jenkinsfile is running to analyze it deeper

    Edited by Carlos Rodriguez Lopez
Please sign in to leave a comment.