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

Declarative Pipeline shows SUCCESS even though job FAILED

    • pipeline-model-definition 1.3.7

      Pipelines are "failing" with SUCCESS status. 

      This pipeline, taken from JENKINS-46325 illustrates this issue successfully:

      pipeline {
          agent any
          stages {
              stage ('Init') {
                  steps {
                      echo "Init result: ${currentBuild.result}"
                      echo "Init currentResult: ${currentBuild.currentResult}"
                  }
                  post {
                      always {
                          echo "Post-Init result: ${currentBuild.result}"
                          echo "Post-Init currentResult: ${currentBuild.currentResult}"
                      }
                  }
              }
              stage ('Build') {
                  steps {
                      echo "During Build result: ${currentBuild.result}"
                      echo "During Build currentResult: ${currentBuild.currentResult}"
                      sh 'exit 1'
                  }
                  post {
                      always {
                          echo "Post-Build result: ${currentBuild.result}"
                          echo "Post-Build currentResult: ${currentBuild.currentResult}"
                      }
                  }
              }
          }
          post {
              always {
                  echo "Pipeline result: ${currentBuild.result}"
                  echo "Pipeline currentResult: ${currentBuild.currentResult}"
              }
          }
      }
      

       

      My results are (trimmed down):

      Running on build-096575a3-e6af-4fff-9ca1-84cc46ba4b86-f9b8d29c in /var/vcap/data/jenkins-slave/workspace/test-job
      Init result: null
      Init currentResult: SUCCESS
      Post stage
      Post-Init result: null
      Post-Init currentResult: SUCCESS
      During Build result: null
      During Build currentResult: SUCCESS
      [Pipeline] sh
      + exit 1
      Post stage
      Post-Build result: null
      Post-Build currentResult: SUCCESS
      Pipeline result: null
      Pipeline currentResult: SUCCESS
      ERROR: script returned exit code 1
      Finished: FAILURE
      

       

          [JENKINS-56402] Declarative Pipeline shows SUCCESS even though job FAILED

          Andrew Bayer added a comment -

          Hopefully this week - we’re trying to solve a bug in the original fix that created this problem in the first place, but if we aren’t able to nail that down in the next couple days, I’ll release 1.3.7 as it is now.

          Andrew Bayer added a comment - Hopefully this week - we’re trying to solve a bug in the original fix that created this problem in the first place, but if we aren’t able to nail that down in the next couple days, I’ll release 1.3.7 as it is now.

          Andrew Bayer added a comment -

          Released just now as 1.3.7 - let us know if you see any problems and we'll get on them ASAP!

          Andrew Bayer added a comment - Released just now as 1.3.7 - let us know if you see any problems and we'll get on them ASAP!

          Felix Retter added a comment -

          Thanks Andrew. 1.3.7 looks very promising

          Felix Retter added a comment - Thanks Andrew. 1.3.7 looks very promising

          Liam Newman added a comment -

          Bulk closing resolved issues.

          Liam Newman added a comment - Bulk closing resolved issues.

          Artour Klevin added a comment -

          With current version 1.5.0 of Pipeline: Declarative Plugin.
          I get the same issue.
           

          Artour Klevin added a comment - With current version 1.5.0 of Pipeline: Declarative Plugin. I get the same issue.  

          Devin Nusbaum added a comment -

          artour If you reopen an old issue, please include a full reproduction case of the issue you are seeing, and describe the actual and expected behavior. In this case, since the issue has been fixed since March, it would be better to open a new ticket to track whatever issue you are seeing separately, so I am going to re-close this issue.

          Devin Nusbaum added a comment - artour If you reopen an old issue, please include a full reproduction case of the issue you are seeing, and describe the actual and expected behavior. In this case, since the issue has been fixed since March, it would be better to open a new ticket to track whatever issue you are seeing separately, so I am going to re-close this issue.

          chirs damour added a comment -

          For people who reported watched this issue its nice that the issue is reopened because it gets it on our radar. Forcing A new issue is a disservice to your hard core issue reporting users who wouldnt get notified

          But totally should have recreate steps

          chirs damour added a comment - For people who reported watched this issue its nice that the issue is reopened because it gets it on our radar. Forcing A new issue is a disservice to your hard core issue reporting users who wouldnt get notified But totally should have recreate steps

          Devin Nusbaum added a comment -

          drdamour By all means, if you open a new issue that is related to an old issue, please comment on the old issue mentioning that you saw something similar, include a link to the new issue, and add a "relates to" issue link in Jira to the other issue. I think it is ok to reopen an issue if you do so very soon after it was originally resolved/closed, since the context is still the same, but given this issue was originally closed in March 2019, I think we need to reevaluate any related issue from scratch. For example, is the fix completely broken (hopefully not, we added some regression tests with the fix), is this a slightly different use case, does it only break when using matrix or parallel, etc.

          Devin Nusbaum added a comment - drdamour By all means, if you open a new issue that is related to an old issue, please comment on the old issue mentioning that you saw something similar, include a link to the new issue, and add a "relates to" issue link in Jira to the other issue. I think it is ok to reopen an issue if you do so very soon after it was originally resolved/closed, since the context is still the same, but given this issue was originally closed in March 2019, I think we need to reevaluate any related issue from scratch. For example, is the fix completely broken (hopefully not, we added some regression tests with the fix), is this a slightly different use case, does it only break when using matrix or parallel , etc.

          Artour Klevin added a comment -

          Sorry for just re-opening it without adding more information.
          It looked very similar to my problem, but after spending another day on it, I have no issues.

          I just set the curentBuild.result = 'FAILURE' in the catch when my step fails in the pipeline.
          Then everything works as I would like it to.

          Thanks for keeping the plugin alive! 

          Artour Klevin added a comment - Sorry for just re-opening it without adding more information. It looked very similar to my problem, but after spending another day on it, I have no issues. I just set the curentBuild.result = 'FAILURE' in the catch when my step fails in the pipeline. Then everything works as I would like it to. Thanks for keeping the plugin alive! 

          Bug, mentioned in the description of this task is still present on latest Jenkins (Jenkins 2.375.1):

          Failed in branch build_check
          currentBuild.result:null
          currentBuild.currentResult:SUCCESS
          ...
          Finished: FAILURE

          qwertytmp1 qwertytmp1 added a comment - Bug, mentioned in the description of this task is still present on latest Jenkins ( Jenkins 2.375.1 ): Failed in branch build_check currentBuild.result:null currentBuild.currentResult:SUCCESS ... Finished: FAILURE

            Unassigned Unassigned
            pzozobrado Philip Zozobrado
            Votes:
            23 Vote for this issue
            Watchers:
            42 Start watching this issue

              Created:
              Updated: