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

catchError(buildResult: hudson.model.Result.SUCCESS, stageResult: hudson.model.Result.FAILURE) doesn't set stage to FAILURE

    Details

    • Similar Issues:

      Description

      If I have a stage with a step in it:

                               ...
                               catchError(buildResult: hudson.model.Result.SUCCESS,
                                         message: 'RPM build failed, but allowing job to continue',
                                         stageResult: hudson.model.Result.FAILURE) {
                                  sh label: env.STAGE_NAME,
                                     script: 'exit 2'
                              }
      

      With a post block for the stage:

                          post {
                              always {
                                  archiveArtifacts artifacts: 'artifacts/**'
                              }
                              success {
                                  println "${env.STAGE_NAME}: SUCCESS"
                              }
                              unstable {
                                  println "${env.STAGE_NAME}: UNSTABLE"
                              }
                              failure {
                                  println "${env.STAGE_NAME}: FAILED"
                              }
                          }
      

       I actually get the:

      My Test Stage: SUCCESS
      

      telling me that the stage was a SUCCESS, not a FAILURE like the:

      catchError(..., stageResult: hudson.model.Result.FAILURE) is supposed to be making it.

      In both the stage view and the Blue Ocean view, it does show as a failed stage. The post processing block just doesn't see it that way.

      As an aside, is there a variable set for the stage that I could use in my println above so that I could just do a single println in the always block rather than having to repeat it through the success, unstable and failure blocks?

        Attachments

          Issue Links

            Activity

            brianjmurrell Brian J Murrell created issue -
            dnusbaum Devin Nusbaum made changes -
            Field Original Value New Value
            Link This issue relates to JENKINS-45579 [ JENKINS-45579 ]
            dnusbaum Devin Nusbaum made changes -
            Labels pipeline
            dnusbaum Devin Nusbaum made changes -
            Component/s pipeline-model-definition-plugin [ 21706 ]
            Component/s pipeline [ 21692 ]
            abayer Andrew Bayer made changes -
            Assignee Andrew Bayer [ abayer ]
            abayer Andrew Bayer made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            abayer Andrew Bayer made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            abayer Andrew Bayer made changes -
            Remote Link This issue links to "PR #330 (Web Link)" [ 23053 ]
            abayer Andrew Bayer made changes -
            Status In Review [ 10005 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            bitwiseman Liam Newman made changes -
            Status Resolved [ 5 ] Closed [ 6 ]

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                brianjmurrell Brian J Murrell
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: