Skip to content

Commit

Permalink
Improving status propagation code in pipelines (adoptium#759)
Browse files Browse the repository at this point in the history
We don't seem to allow for the pipeline to have a null status,
which the API tells us is possible when calling getResult().

I've patched this logic gap and added some better logging to aid
future debugging.

Signed-off-by: Adam Farley <[email protected]>
  • Loading branch information
adamfarley authored and luhenry committed Feb 3, 2024
1 parent a4e407b commit 359ebe9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pipelines/build/common/build_base_file.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -914,13 +914,19 @@ class Builder implements Serializable {
}
context.println '[NODE SHIFT] OUT OF CONTROLLER NODE!'

if ((downstreamJob.getResult() != 'SUCCESS' || !copyArtifactSuccess) && propagateFailures) {
if (propagateFailures) {
String previousPipelineStatus = currentBuild.result
context.println("Propagating downstream job result: ${downstreamJobName}, Result: "+downstreamJob.getResult()+" CopyArtifactsSuccess: "+copyArtifactSuccess)
if (copyArtifactSuccess && downstreamJob.getResult() == 'UNSTABLE' && (currentBuild.result == 'SUCCESS' || currentBuild.result == 'UNSTABLE' )) {
currentBuild.result = 'UNSTABLE'
if (copyArtifactSuccess) {
// currentBuild.result only allows itself to be set if the new status is worse than its current status.
// So FAILURE overrides UNSTABLE, and UNSTABLE overrides SUCCESS.
context.println("Attempting to set pipeline result to \""+downstreamJob.getResult()+"\".")
currentBuild.result = downstreamJob.getResult()
} else {
context.println("Attempting to set pipeline result to \"FAILURE\".")
currentBuild.result = 'FAILURE'
}
context.println("Attempt complete. Pipeline status was \""+previousPipelineStatus+"\", and is now \""+currentBuild.result+"\".")
}
}
}
Expand Down

0 comments on commit 359ebe9

Please sign in to comment.