You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use case
--------
My use case is a post build script trigger a job which does not need to
fully complete. The step can be cancelled while waiting (or building)
and that caused the triggering build to be marked as a failure.
To fix that, I need the plugin to pass the result of the build step
through BlockingBehaviour which lets one define how to behave when the
triggered build got NOT_BUILT or ABORTED, in my case I need it to never
block.
See: https://phabricator.wikimedia.org/T352319
Solution
--------
There are multiple reasons for a job to not fully complete:
- it is interrupted, an InterruptedException is thrown, this is still
rethrow and Jenkins will make the build as ABORTED.
- it can be cancelled from the build queue raising a
CancellationException. This previously raised an AbortException which
marks the build as a failure, I have changed it to a NOT_BUILT result
which can be process as other results (notably never block on it).
The Jenkins Result class ranks the results as:
- SUCCESS
- UNSTABLE
- FAILURE
- NOT_BUILT
- ABORTED.
The NOT_BUILT and ABORTED results are thus worse than a FAILURE and
would be matched as such in BlockingBehavior mapBuildStepResult() and
mapBuildResult() which uses isWorseOrEqualTo() for comparison.
Add a test testCancelledFromBuildQueue() to cover the
CancellationException() is caught and it results in a SUCCESS (since the
test blocking behavior is to never block).
ResultConditionTest covers the BlockingBehavior is able to map NOT_BUILD
and ABORTED since it has two tests explicitly cancelling and
interrupting jobs.
Examples
--------
When a build is aborted, by aborting it:
Waiting for the completion of downstream-project
downstream-project #7 started.
downstream-project #7 completed. Result was ABORTED
Build step 'Trigger/call builds on other projects' marked build as failure
Finished: FAILURE
When it is waiting in the build queue and cancelled:
Waiting for the completion of downstream-project
Not built: downstream-project has been cancelled while waiting in the queue.
Build step 'Trigger/call builds on other projects' marked build as failure
Finished: FAILURE
0 commit comments