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

Declarative Pipeline Parallel Stages Post Events non-deterministic

      The Jenkins Declarative Pipeline is experiencing non-deterministic results when entering the post steps for parallel stages. For example, when an error is raised in one of two parallel stages and the other stage succeeds, but finish around the same time, then the successful stage executes the failure post stage, instead of the successful.

      stage("Parallel stages") {
          parallel {
              stage("Stage 1"){
                  agent none
                  steps {
                      script {
                          // sleep 10 // when sleeping long enough, stages behave correctly.
                          error("Which post step will get executed?")
                      }
                  }
                  post {
                      success {
                          echo "Stage 1 success!"
                      }
                      failure {
                          echo "Stage 1 failure!"
                      }
                  }
              }
              stage("Stage 2"){
                  agent none
                  steps {
                      script {
                          echo "Stage 2 code executing..."
                      }
                  }
                  post {
                      success {
                          echo "Stage 2 success!"
                      }
                      failure {
                          echo "Stage 2 failure!"
                      }
                  }
              }
          }
          post {
              success {
                  echo "Parallel post steps success!"
              }
              failure {
                  echo "Parallel post steps failure!"
              }
          }
      }

       

      So when Stage 1 has the sleep step commented out the results I see are:

      [Stage 1] Stage 1 failure!

      [Stage 2] Stage 2 failure!

      Parallel post steps failure!

       

      But when Stage 1 has the sleep step active, the results I see are:

      [Stage 1] Stage 1 failure!

      [Stage 2] Stage 2 success!

      Parallel post steps failure!

       

      I should expect the second scenario in all situations, right?

          [JENKINS-52114] Declarative Pipeline Parallel Stages Post Events non-deterministic

          Brandon Klos created issue -
          Andrew Bayer made changes -
          Component/s Original: core [ 15593 ]
          Andrew Bayer made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Andrew Bayer made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]
          Andrew Bayer made changes -
          Remote Link New: This issue links to "PR #285 (Web Link)" [ 21345 ]
          Andrew Bayer made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: In Review [ 10005 ] New: Resolved [ 5 ]
          Liam Newman made changes -
          Status Original: Resolved [ 5 ] New: Closed [ 6 ]

            abayer Andrew Bayer
            bklos Brandon Klos
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: