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

catchError - Expecting "class hudson.model.Result" for parameter "buildResult"

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • pipeline
    • None
    • workflow-basic-steps 2.18

      Used pipeline:

      pipeline {
          agent any
          stages {
              stage('catch error') {
                  steps {
                      catchError(buildResult: 'SUCCESS') {
                          sh "exit 1"
                      }
                  }
              }
              stage('summary') {
                  steps {
                      echo "here comes the summary..."
                  }
              }
          }
      }
      

      Result:

      Running in Durability level: MAX_SURVIVABILITY
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      WorkflowScript: 6: Expecting "class hudson.model.Result" for parameter "buildResult" but got "SUCCESS" of type class java.lang.String instead @ line 6, column 41.
               catchError(buildResult: 'SUCCESS')
                                       ^
      
      1 error
      
      	at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
      	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1085)
      	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
      	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
      	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
      	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
      	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
      	at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
      	at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
      	at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:133)
      	at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:126)
      	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:561)
      	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:522)
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:320)
      	at hudson.model.ResourceController.execute(ResourceController.java:97)
      	at hudson.model.Executor.run(Executor.java:429)
      Finished: FAILURE
      

       

          [JENKINS-57537] catchError - Expecting "class hudson.model.Result" for parameter "buildResult"

          Thanks for looking into this. Is there anything I can help with?

          Torsten Walter added a comment - Thanks for looking into this. Is there anything I can help with?

          Devin Nusbaum added a comment -

          I was able to reproduce the issue and can confirm that this is specific to Declarative Pipelines. I am working on a PR to fix the issue: https://github.com/jenkinsci/workflow-basic-steps-plugin/pull/85.

          Devin Nusbaum added a comment - I was able to reproduce the issue and can confirm that this is specific to Declarative Pipelines. I am working on a PR to fix the issue: https://github.com/jenkinsci/workflow-basic-steps-plugin/pull/85 .

          Devin Nusbaum added a comment - - edited

          A fix for this issue was just released in Pipeline Basic Steps Plugin version 2.18. Note that you must update Pipeline Groovy Plugin to version 2.70 along with this update.

          Devin Nusbaum added a comment - - edited A fix for this issue was just released in Pipeline Basic Steps Plugin version 2.18. Note that you must update Pipeline Groovy Plugin to version 2.70 along with this update.

          Andrei Muresianu added a comment - - edited

          Thank you for working on this dnusbaum!

          Could you please let me know if my expectation is wrong? I tried running the following:

          pipeline {
              agent any
              stages {
                  stage('catch error') {
                      steps {
                          catchError(stageResult: 'UNSTABLE') {
                              sh "exit 1"
                          }
                      }
                  }
                  stage('summary') {
                      steps {
                          echo "here comes the summary..."
                      }
                  }
              }
          } 

          And I expected the first stage to turn yellow instead it stayed green.

          I can confirm that I am running:

          Pipeline Basic Steps 2.17 and Pipeline Groovy: 2.70

          Andrei Muresianu added a comment - - edited Thank you for working on this  dnusbaum ! Could you please let me know if my expectation is wrong? I tried running the following: pipeline { agent any stages { stage( ' catch error' ) { steps { catchError(stageResult: 'UNSTABLE' ) { sh "exit 1" } } } stage( 'summary' ) { steps { echo "here comes the summary..." } } } } And I expected the first stage to turn yellow instead it stayed green. I can confirm that I am running: Pipeline Basic Steps 2.17 and Pipeline Groovy: 2.70

          Devin Nusbaum added a comment -

          andreimuresianu Yes, it should turn yellow in your example. I think that JENKINS-57579 is that problem, and we are waiting on a Blue Ocean fix to be merged and released to fix it. (In some cases, things work without the fix, but I think sequential stages are problematic.)

          Devin Nusbaum added a comment - andreimuresianu  Yes, it should turn yellow in your example. I think that  JENKINS-57579 is that problem, and we are waiting on a Blue Ocean fix to be merged and released to fix it. (In some cases, things work without the fix, but I think sequential stages are problematic.)

          Hello, Did anyone ever solve this issue for Declarative pipeline? The catchError still give the same error.

          Andrew Mullens added a comment - Hello, Did anyone ever solve this issue for Declarative pipeline? The catchError still give the same error.

          Devin Nusbaum added a comment -

          wamcubs Yes, this issue is fixed, see this comment. Make sure you are passing a String to catchError and not an object of type Result. If that still isn't working for you, please post an extract from your Jenkinsfile showing how you are using catchError.

          Devin Nusbaum added a comment - wamcubs Yes, this issue is fixed, see this comment . Make sure you are passing a String to catchError and not an object of type Result . If that still isn't working for you, please post an extract from your Jenkinsfile showing how you are using catchError .

          Hey Devin, thank you. I saw that and was passing in a string, but turns out our Plug in Version is 2.66. So it should work once we update the plug in. Thanks again.

          Andrew Mullens added a comment - Hey Devin, thank you. I saw that and was passing in a string, but turns out our Plug in Version is 2.66. So it should work once we update the plug in. Thanks again.

          Robin Björklin added a comment - - edited

          Can anyone get the message to show?

          catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS', message: 'Not triggering downstream build.') {
              build job: "test/build", wait: false
          }
          

           EDIT: It shows up in the ConsoleText but not in Blue Ocean. Intended?

          Robin Björklin added a comment - - edited Can anyone get the message to show? catchError(buildResult: 'SUCCESS' , stageResult: 'SUCCESS' , message: 'Not triggering downstream build.' ) { build job: "test/build" , wait: false }  EDIT: It shows up in the ConsoleText but not in Blue Ocean. Intended?

          Am I doing something wrong here? 

          catchError(buildResult: hudson.model.Result.UNSTABLE, stageResult: hudson.model.Result.FAILURE) {
          //build steps
          }

          We just updated from v2.16 to v2.204 this morning and this line (and similar) has been causing our declarative pipelines to break. I'm not sure what the right format is

          Anvesh Gundlapalli added a comment - Am I doing something wrong here?  catchError(buildResult: hudson.model.Result.UNSTABLE, stageResult: hudson.model.Result.FAILURE) { //build steps } We just updated from v2.16 to v2.204 this morning and this line (and similar) has been causing our declarative pipelines to break. I'm not sure what the right format is

            dnusbaum Devin Nusbaum
            twalter Torsten Walter
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: