Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Won't Fix
-
None
Description
When parallel steps use a new node, and throws an error, the Stage View displays the wrong stage as failing
example pipeline:
try{ parallel a: { execute_function('A') }, b: { execute_function('B') }, c: { execute_function('C') }, failFast: false } finally { stage 'Cleanup' echo "done with all" } def execute_function(name){ try { stage "${name}" node { if(name == 'B'){ echo "FAILING HERE"; error 'died' } else if (name == 'A') { echo "sleeping"; sleep 25; } echo "future steps" } } catch(e) { echo "error: ${e.toString()}"; throw e } }
here's a snippet of the console log (you can see that stage 'B' is where the error occurs):
[a] Entering stage A [a] Proceeding [Pipeline] [a] Allocate node : Start [a] Running on master in /var/lib/jenkins/workspace/failfast [Pipeline] [b] stage (B) [b] Entering stage B [b] Proceeding .... [a] sleeping [Pipeline] [a] sleep [Pipeline] [b] echo [b] FAILING HERE [Pipeline] [b] error [Pipeline] } //node [Pipeline] [c] echo [c] future steps [Pipeline] } //node [Pipeline] Allocate node : End [Pipeline] Allocate node : End [Pipeline] echo error: hudson.AbortException: died [Pipeline] } //parallel [Pipeline] } //parallel [Pipeline] [a] echo [a] future steps .... Entering stage Cleanup Proceeding [Pipeline] echo done with all [Pipeline] End of Pipeline org.jenkinsci.plugins.workflow.cps.steps.ParallelStepException: Parallel step b failed
The attached screenshot shows that stage 'C' failed.
And when clicking to see the logs, all the stage logs are compiled into the one 'C' view, and the error message is mixed in with stage 'A' and stage 'B' logs.
NOTE:
if you remove the node{} from inside execute_function() and execute the pipeline, the display functions as expected
Unfortunately, as currently implemented, stage steps cannot be used correctly within parallel blocks. This is a limitation of how stages are implemented in the pipeline, not the UI itself. You may use a stage that contains parallel blocks, however (in which case the stage will show as successful if and only if all parallel components succed).
Since it's a fairly common assumption, there's a mention within the in the Pipeline Stage View limitations/usage notes on the wiki: https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Stage+View+Plugin
There is work in progress to provide a new step that can be used within parallel blocks to mark their progress: https://issues.jenkins-ci.org/browse/JENKINS-26107
Please see also: https://issues.jenkins-ci.org/browse/JENKINS-33185 which is planned work to offer better visualization of parallel branches within a stage (there are multiple people including me working towards that, but it is complex and will take a while to implement).