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

Declarative Pipeline shows SUCCESS even though job FAILED

XMLWordPrintable

    • 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
      

       

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

              Created:
              Updated: