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

catchError(stageResult: 'UNSTABLE', buildResult: 'UNSTABLE') in post->success causes all other stages to be unsuccessful

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Incomplete
    • Icon: Blocker Blocker
    • pipeline
    • None
    • Jenkins 2.303.1

      This may be a duplicate of JENKINS-57801, but in case it's subtly different and not, I will open a new issue here.

      Given this pipeline:

      pipeline {
          agent { label 'lightweight' }
          stages {
              stage('Build') {
                  parallel {
                      stage('SUCCESSful stage, SUCCESSful build') {
                          steps {
                              sh script: 'sleep 5; exit 0'
                          } 
                          post {
                              success {
                                  echo "post -> success"
                                  sh script: 'exit 0'
                              }
                              unsuccessful {
                                  echo "post -> unsuccessful"
                              }
                          }
                      }
                      stage('Set\'s UNSTABLE stage, SUCCESSful build in post -> success') {
                          steps {
                              sh script: 'exit 0'
                          }
                          post {
                              success {
                                  echo "post -> success"
                                  catchError(stageResult: 'UNSTABLE', buildResult: 'UNSTABLE') {
                                      error('build->success error() call')
                                  }
                              }
                              unsuccessful {
                                  echo "post -> unsuccessful"
                              }
                          }
                      }
                      stage('SUCCESSful stage, SUCCESSful build after 10s') {
                          steps {
                              sh script: 'sleep 10; exit 0'
                          }
                          post {
                              success {
                                  echo "post -> success"
                                  sh script: 'exit 0'
                              }
                              unsuccessful {
                                  echo "post -> unsuccessful"
                              }
                          }
                      }
                  } 
              } 
          }
      }
      

      I would expect the two SUCCESSful stage, SUCCESSful build stages to execute their post -> success blocks. However they do not. They both execute their post -> unsuccessful blocks:

            Unassigned Unassigned
            brianjmurrell Brian J Murrell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: