Skip to content
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 @@ -678,20 +678,19 @@ private interface OutputSupplier {
byte[] produce() throws IOException, InterruptedException;
}
private void handleExit(int exitCode, OutputSupplier output) throws IOException, InterruptedException {
Throwable originalCause = causeOfStoppage;
if ((returnStatus && originalCause == null) || exitCode == 0) {
getContext().onSuccess(returnStatus ? exitCode : returnStdout ? new String(output.produce(), StandardCharsets.UTF_8) : null);
} else {
if (causeOfStoppage != null) {
getContext().onFailure(causeOfStoppage);
} else if (returnStatus) {
Comment on lines +681 to +683
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to make the logic of this method more legible.

getContext().onSuccess(exitCode);
} else if (exitCode != 0) {
if (returnStdout) {
_listener().getLogger().write(output.produce()); // diagnostic
}
if (originalCause != null) {
// JENKINS-28822: Use the previous cause instead of throwing a new AbortException
_listener().getLogger().println("script returned exit code " + exitCode);
getContext().onFailure(originalCause);
} else {
getContext().onFailure(new AbortException("script returned exit code " + exitCode));
}
getContext().onFailure(new AbortException("script returned exit code " + exitCode));
} else if (returnStdout) {
getContext().onSuccess(new String(output.produce(), StandardCharsets.UTF_8));
} else {
getContext().onSuccess(null);
}
listener().getLogger().close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ private static final class HelloNote extends ConsoleNote<Run<?, ?>> {
j.waitForCompletion(b);
// Would have succeeded before https://github.com/jenkinsci/workflow-durable-task-step-plugin/pull/75.
j.assertBuildStatus(Result.ABORTED, b);
j.waitForMessage("Timeout has been exceeded", b); // TODO assertLogContains fails unless a sleep is introduced; possible race condition in waitForCompletion
j.assertLogContains("Timeout has been exceeded", b);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverting #84 (comment)

}

@Issue("JENKINS-62014")
Expand Down
Loading