Stage B is not skipped due to failure in stage A's nested stage

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

XMLWordPrintable

      After testing the new nested sequential stages feature in version 1.3 of pipeline-model-definition recently released, I found that the error handling is not working as (I) expected. Given this minimal Jenkinsfile

      pipeline {
          agent none
          stages {
              stage('A') {
                  stages {
                      stage('A.1') {
                          steps {
                              error('Error in stage A.1')
                          }
                      }
                  }
              }
              stage('B') {
                  steps {
                      echo('Executing stage B')
                  }
              }
          }
      }

      I expect that stage B is not executed, but it is, as the console output shows:

      Branch indexing
       > git rev-parse --is-inside-work-tree # timeout=10
      Setting origin to git@git:verification
       > git config remote.origin.url git@git:verification # timeout=10
      Fetching origin...
      Fetching upstream changes from origin
       > git --version # timeout=10
      using GIT_SSH to set credentials 
       > git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*
      Seen branch in repository origin/master
      Seen branch in repository origin/work/TEST-1234
      Seen 2 remote branches
      Obtained Jenkinsfile from fbd58047af16f0ab665ec6d550d21ceff1e91cfb
      Running in Durability level: MAX_SURVIVABILITY
      First time build. Skipping changelog.
      [Pipeline] stage
      [Pipeline] { (A)
      [Pipeline] stage
      [Pipeline] { (A.1)
      [Pipeline] error
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] stage
      [Pipeline] { (B)
      [Pipeline] echo
      Executing stage B
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] End of Pipeline
      Finished: FAILURE

      Given a pipeline without nested stages the behaviour is as expected; stage B is skipped when stage A fails:

      pipeline {
          agent none
          stages {
              stage('A') {
                  steps {
                      error('Error in stage A')
                  }
              }
              stage('B') {
                  steps {
                      echo('Executing stage B')
                  }
              }
          }
      }

      Console output shows that stage B is skipped:

      Branch indexing
       > git rev-parse --is-inside-work-tree # timeout=10
      Setting origin to git@git:verification
       > git config remote.origin.url git@git:verification # timeout=10
      Fetching origin...
      Fetching upstream changes from origin
       > git --version # timeout=10
      using GIT_SSH to set credentials 
       > git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*
      Seen branch in repository origin/master
      Seen branch in repository origin/work/TEST-1234
      Seen 2 remote branches
      Obtained Jenkinsfile from 203fe77650dbdd5392790cfe53558d7ef67fe0de
      Running in Durability level: MAX_SURVIVABILITY
      First time build. Skipping changelog.
      [Pipeline] stage
      [Pipeline] { (A)
      [Pipeline] error
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] stage
      [Pipeline] { (B)
      Stage "B" skipped due to earlier failure(s)
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] End of Pipeline
      ERROR: Error in stage A
      Finished: FAILURE

            Assignee:
            Andrew Bayer
            Reporter:
            Thomas Johansen
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: