Skip to content

Commit

Permalink
Avoid logging when setResult is predicted to do nothing #308 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Apr 26, 2024
1 parent cfa55a8 commit 6a6e341
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,12 @@ public Object readResolve() {
Functions.printStackTrace(t, listener.getLogger());
}
if (buildResult.isWorseThan(Result.SUCCESS)) {
listener.getLogger().println("Setting overall build result to " + buildResult);
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

0 comments on commit 6a6e341

Please sign in to comment.