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

Declarative Pipeline shows SUCCESS even though job FAILED

    XMLWordPrintable

Details

    • pipeline-model-definition 1.3.7

    Description

      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
      

       

      Attachments

        Issue Links

          Activity

            dnusbaum 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.

            dnusbaum 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.
            drdamour 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

            drdamour 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
            dnusbaum 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.

            dnusbaum 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 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 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 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

            People

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

              Dates

                Created:
                Updated: