Skip to content
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

Log a note when catchError sets build result #308

Merged
merged 2 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,12 @@
Functions.printStackTrace(t, listener.getLogger());
}
if (buildResult.isWorseThan(Result.SUCCESS)) {
context.get(Run.class).setResult(buildResult);
Run<?, ?> build = context.get(Run.class);
Result currentResult = build.getResult();
if (currentResult == null || buildResult.isWorseThan(currentResult)) {

Check warning on line 253 in src/main/java/org/jenkinsci/plugins/workflow/steps/CatchErrorStep.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 253 is only partially covered, 3 branches are missing
listener.getLogger().println("Setting overall build result to " + buildResult);
} // otherwise WorkflowRun.setResult should be a no-op, so do not log anything
build.setResult(buildResult);
}
if (stepResult.isWorseThan(Result.SUCCESS)) {
context.get(FlowNode.class).addOrReplaceAction(new WarningAction(stepResult).withMessage(message));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public class CatchErrorStepTest {
"}", true));
WorkflowRun b = p.scheduleBuild2(0).waitForStart();
assertCatchError(r, b, Result.UNSTABLE, null, true);
r.assertLogContains("Setting overall build result to UNSTABLE", b);
}

@Test public void invalidBuildResult() throws Exception {
Expand Down