-
Bug
-
Resolution: Unresolved
-
Minor
-
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)