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

When a stage fails the currentBuild, following stages that pass will still execute the failure block in that stage's post block

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • core
    • None
    • 2.426.3 and 2.440.1

      pipeline {
          agent {
              node

      {             label "master"         }

          }
        stages {

          stage("test") {
              steps {
                  catchError(buildResult:"FAILURE",stageResult:"FAILURE")

      {                 sh "exit -1"             }

              }
              post {
                  failure {
                      println "${env.STAGE_NAME} failed"
                  }
              }
          }
          stage("test2") {
              steps

      {                 sh "exit 0"         }

              post {
                  failure {
                      println "${env.STAGE_NAME} failed"
                  }
                  success {
                      println "${env.STAGE_NAME} passed"
                  }
              }
          }

        }       

      }

       

      I expect that the post for stage2 would execute the success block, but instead it executes the failure block.

            Unassigned Unassigned
            ajbarber Andrew Barber
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: