-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JENKINS-49073] Propagate the downstream result, not just FAILURE #24
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! FWIW BuildTriggerListener.java line 48 looks like a good place to add a WarningAction
when !trigger.propagate && run.getResult() != Result.SUCCESS
, but that's unrelated.
Note that you have to set expectations carefully, since users may come to expect this warning to appear, when in fact it will only appear if the upstream happens to run longer than the downstream. |
I'm a bit nervous to upgrade to |
I think this makes sense, assuming a suitable definition of “worst”: success > … >
Or an explicit option in the |
Thanks as always for your pertinent insights, @jglick. I opened jenkinsci/workflow-cps-plugin#325 to address this. |
@@ -49,7 +50,8 @@ public void onCompleted(Run<?,?> run, @Nonnull TaskListener listener) { | |||
trigger.context.onFailure(trigger.interruption); | |||
} | |||
} else { | |||
trigger.context.onFailure(new AbortException(run.getFullDisplayName() + " completed with status " + run.getResult() + " (propagate: false to ignore)")); | |||
Result result = run.getResult(); | |||
trigger.context.onFailure(new FlowInterruptedException(result != null ? result : /* probably impossible */ Result.FAILURE, new DownstreamFailureCause(run))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One side effect of using FlowInterruptedException
instead of AbortException
is that retry
will no longer retry the build
step if it fails (it ignores FlowInterruptedException
because of JENKINS-44379 ). This was reported as a bug in JENKINS-60354.
I'm not really sure how to fix this. I think FlowInterruptedException
is overloaded with too many meanings at this point. One approach would be to factor out a ResultCarryingException
interface, have FlowInterruptedException
and some new FooException
implement that interface, and then go through and switch everything that currently just uses FlowInterruptedException
for a result to use ResultCarryingException
when inspecting exception and FooException
when creating them, and only use FlowInterruptedException
when we only want to capture actual Pipeline interruption.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might rather suggest amending RetryStep
to check for the presence of a CauseOfInterruption
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might rather suggest amending RetryStep to check for the presence of a CauseOfInterruption.
Good idea, and much simpler to implement, although I do feel like it would be good to separate the different use cases of FlowInterruptedException
at some point so that it is easier to reason about changes like this in isolation.
I think catchError
and warnError
probably have the same issue as retry
and would also need to be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it looks like WorkflowRun.doTerm
does not set a CauseOfInterruption
when it aborts the build, so that would need to be tested and maybe changed since it should be rethrown by retry
. WorkflowRun.doKill
does not set a CauseOfInterruption
either, but I don't think it matters in that case because of the way the build is aborted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps just add a fatal
flag to FlowInterruptedException
, used by true build interruptions, and have steps like retry
only ignore it in this mode. I guess that boils down to a similar proposal.
JENKINS-49073
Probably improved by jenkinsci/workflow-step-api-plugin#44.
Note that this may also satisfy the stated use case for #13: