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

currentBuild.currentResult not set to failed

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Critical
    • Resolution: Duplicate
    • Component/s: pipeline
    • Environment:
    • Similar Issues:

      Description

      As stated in #4635 from Liam Newman, currentBuild.currentResult should contain the current state. I used this feature and approximately one or two weeks ago this stopped working-> currentResult never returns FAILURE, even when the post section `failure` is processed correctly. Consider the following pipeline:

       pipeline {
          agent {
              label 'master'
          }
          stages{
              stage('Failing') { 
                  steps{
                          bat 'exit 1'
                  }
                  post {
                      always {
                          echo "Post-Build result: (currentBuild.result, currentBuild.currentResult):"
                          echo "${currentBuild.result}, ${currentBuild.currentResult}"
                      }
                  }
              }
          }
         post {
              failure {
                  echo "Post-Pipeline failure (currentBuild.result, currentBuild.currentResult): "
                  echo "${currentBuild.result}, ${currentBuild.currentResult}"
              }
              success {
                  echo "Post-Pipeline success (currentBuild.result, currentBuild.currentResult): "
                  echo "${currentBuild.result}, ${currentBuild.currentResult}"
              }
         }
      }
      

      I get this output (trimmed):

      Post-Build result: (currentBuild.result, currentBuild.currentResult):
      null, SUCCESS
      Post-Pipeline failure (currentBuild.result, currentBuild.currentResult): 
      null, SUCCESS
      

      (currentBuild.result being null is of course expected)

        Attachments

          Issue Links

            Activity

            Hide
            laeubi Christoph Läubrich added a comment -

            We also have this problem, this is critical for us since now all E-Mails and anouncements always state that the build is successfull!

            Show
            laeubi Christoph Läubrich added a comment - We also have this problem, this is critical for us since now all E-Mails and anouncements always state that the build is successfull!

              People

              • Assignee:
                Unassigned
                Reporter:
                flx Felix Retter
              • Votes:
                2 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: