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

currentBuild.currentResult not set to failed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Critical Critical
    • pipeline

      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)

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

              Created:
              Updated:
              Resolved: