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

Post steps in parallel parent are executed after previous stage failure

    Details

    • Similar Issues:

      Description

      When a pipeline stage fails, subsequent stages execute their "failure" post steps even if they are skipped. This only occurs for stages which host parallel child stages.

       

      Example:

      pipeline {
        agent none
      
        stages {
          stage('One') {
            agent any
      
            steps {
              error('fail')
            }
      
            post {
              failure {
                echo 'One'
              }
          }
      
          stage('Two') {
            agent any
      
            steps {
              echo "Shouldn't run"
            }
      
            post {
              failure {
                echo 'Two'
              }
            }
          }
      
          stage('Three') {
            parallel {
              stage('Child 1') {
                agent any
                steps { echo 'Child 1' }
              }
              stage('Child 2') {
                agent any
                steps { echo 'Chlid 2' }
              }
            }
      
            post {
              failure {
                echo 'Three'
              }
            }
          }
        }
      }

      This will echo:

      One
      Three
      

        Attachments

          Activity

          tad Tad Fisher created issue -
          tad Tad Fisher made changes -
          Field Original Value New Value
          Description When a pipeline stage fails, subsequent stages execute their "failure" post steps even if they are skipped. This only occurs for stages which host parallel child stages.

           

          Example:
          {code:java}
          pipeline {
            agent none

            stages {
              stage('One') {
                agent any

                steps {
                  error('fail')
                }

                post {
                  failure {
                    echo 'One'
                  }
              }

              stage('Two') {
                agent any

                steps {
                  echo "Shouldn't run"
                }

                post {
                  failure {
                    echo 'Two'
                  }
                }
              }

              stage('Three') {
                parallel {
                  stage('Child 1') {
                    agent any
                    steps { echo 'Child 1' }
                  }
                  stage('Child 2') {
                    agent any
                    steps { echo 'Chlid 2' }
                  }
                }

                post {
                  failure {
                    echo 'Three'
                  }
                }
              }
            }
          }{code}
          When a pipeline stage fails, subsequent stages execute their "failure" post steps even if they are skipped. This only occurs for stages which host parallel child stages.

           

          Example:
          {code:java}
          pipeline {
            agent none

            stages {
              stage('One') {
                agent any

                steps {
                  error('fail')
                }

                post {
                  failure {
                    echo 'One'
                  }
              }

              stage('Two') {
                agent any

                steps {
                  echo "Shouldn't run"
                }

                post {
                  failure {
                    echo 'Two'
                  }
                }
              }

              stage('Three') {
                parallel {
                  stage('Child 1') {
                    agent any
                    steps { echo 'Child 1' }
                  }
                  stage('Child 2') {
                    agent any
                    steps { echo 'Chlid 2' }
                  }
                }

                post {
                  failure {
                    echo 'Three'
                  }
                }
              }
            }
          }{code}

          This will echo:


          {noformat}
          One
          Three
          {noformat}
          abayer Andrew Bayer made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          bitwiseman Liam Newman made changes -
          Status Resolved [ 5 ] Closed [ 6 ]

            People

            • Assignee:
              abayer Andrew Bayer
              Reporter:
              tad Tad Fisher
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: