Stefan Eder commented on Bug JENKINS-15900

Took a quick look into the code and found out that the "parallel method" (find it here at about line 257: https://github.com/jenkinsci/build-flow-plugin/blob/master/src/main/groovy/com/cloudbees/plugins/flow/FlowDSL.groovy) does not evaluate the previous flow state (like "build()") and ignores the previous result.

To prove that, I did something like this:

out.println flowRun.state.result
parallel (
  { build("test-b") }, // this build fails
  { build("test-c") }
)
out.println flowRun.state.result
parallel (
  { out.println flowRun.state.result
    build("test-d") },
  { out.println flowRun.state.result
    build("test-e") }
)
out.println flowRun.state.result

Then the output will look something like this:

SUCCESS
parallel {
Trigger job test-b
Trigger job test-c
test-b #1 completed
test-c #1 completed
}
FAILURE
parallel {
SUCCESS
SUCCESS
Trigger job test-e
Trigger job test-f
test-f #1 completed
test-e #1 completed
}
FAILURE

Therefore I think the right result is returned but ignored by the parallel execution. I don't know if this is a feature or a bug. But in the meantime you can do the following workaround:

if (flowRun.state.result.isWorseThan(SUCCESS)) {
  // do something in case of error
} else {
  // do something in case of success
}

Hope that helps somehow.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to