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

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      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.

            Assignee:
            Unassigned
            Reporter:
            Andrew Barber
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Archived: