Skip to content

Commit

Permalink
Merge pull request #308 from jglick/catchError
Browse files Browse the repository at this point in the history
Log a note when `catchError` sets build result
  • Loading branch information
jglick authored Apr 26, 2024
2 parents bf550f7 + 6a6e341 commit cbfc1e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,12 @@ public Object readResolve() {
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

0 comments on commit cbfc1e3

Please sign in to comment.