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

Stage result unchangeable after parallel step

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • workflow-cps-plugin
    • None
    • workflow-cps version: 3731.ve4b_5b_857b_a_d3
      Jenkins version: 2.401.2

      After parallel step, stage result (as observed through Stage View/wfapi) will be fixed to the result of the parallel step. Steps that follow within the same stage do not affect the stage result (build result works as expected).

      For example, the following pipeline has a parallel step that succeeds and after that a step that fails.

      Expected behavior:

      • build result: FAILURE
      • stage result: FAILURE

      Actual behavior:

      • build result: FAILURE
      • stage result: SUCCESS (=result of parallel step)

       

      node {
          stage('shouldFail') {
              def parallelMap = [
                  'foo': {
                      println 'foo'
                  },
                  'bar': {
                      println 'bar'
                  }
              ]
              
              parallel parallelMap // successful parallel step
              error 'Error after parallel step'
          }
      }
      

       

       

      Same behavior can be observed when the parallel step is used inside a script block of a declarative pipeline. Interestingly, the execution of post blocks is not affected and works as expected. In the example below, post blocks for stage failure and pipeline failure run.

       

      pipeline {
          agent any
          stages {
              stage('ShouldFail') {
                  steps {
                      script {
                          def parallelMap = [
                              foo: {
                                  println "foo"
                              },
                              bar: {
                                  println "bar"
                              }
                          ]                    
                          parallel parallelMap // successful parallel step
                          error "Error after parallel step"
                      }
                  }
                  post {
                      success {
                          println 'Post Stage: SUCCESS'
                      }
                      failure {
                          println 'Post Stage: FAILURE'
                      }
                  }
              }
          }
          post {
              success {
                  println 'Post Pipeline: SUCCESS'
              }
              failure {
                  println 'Post Pipeline: FAILURE'
              }
          }
      } 

       

       

       

      I found two Workarounds for this issue:

      • Ensure parallel step is the very last step of a stage
      • Use parallel section (only declarative pipeline)

            Unassigned Unassigned
            lars_licha Lars
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: