Skip to content

Commit 88cd1c2

Browse files
committed
Merge branch 'master' of https://github.com/jenkinsci/workflow-durable-task-step-plugin into migrate_to_junit5
2 parents e9fb96b + 56e587f commit 88cd1c2

3 files changed

Lines changed: 11 additions & 13 deletions

File tree

src/main/java/org/jenkinsci/plugins/workflow/steps/durable_task/DurableTaskStep.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -678,20 +678,19 @@ private interface OutputSupplier {
678678
byte[] produce() throws IOException, InterruptedException;
679679
}
680680
private void handleExit(int exitCode, OutputSupplier output) throws IOException, InterruptedException {
681-
Throwable originalCause = causeOfStoppage;
682-
if ((returnStatus && originalCause == null) || exitCode == 0) {
683-
getContext().onSuccess(returnStatus ? exitCode : returnStdout ? new String(output.produce(), StandardCharsets.UTF_8) : null);
684-
} else {
681+
if (causeOfStoppage != null) {
682+
getContext().onFailure(causeOfStoppage);
683+
} else if (returnStatus) {
684+
getContext().onSuccess(exitCode);
685+
} else if (exitCode != 0) {
685686
if (returnStdout) {
686687
_listener().getLogger().write(output.produce()); // diagnostic
687688
}
688-
if (originalCause != null) {
689-
// JENKINS-28822: Use the previous cause instead of throwing a new AbortException
690-
_listener().getLogger().println("script returned exit code " + exitCode);
691-
getContext().onFailure(originalCause);
692-
} else {
693-
getContext().onFailure(new AbortException("script returned exit code " + exitCode));
694-
}
689+
getContext().onFailure(new AbortException("script returned exit code " + exitCode));
690+
} else if (returnStdout) {
691+
getContext().onSuccess(new String(output.produce(), StandardCharsets.UTF_8));
692+
} else {
693+
getContext().onSuccess(null);
695694
}
696695
listener().getLogger().close();
697696
}

src/test/java/org/jenkinsci/plugins/workflow/steps/durable_task/ShellStepTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ void interruptingAbortsBuildEvenWithReturnStatus() throws Exception {
808808
j.waitForCompletion(b);
809809
// Would have succeeded before https://github.com/jenkinsci/workflow-durable-task-step-plugin/pull/75.
810810
j.assertBuildStatus(Result.ABORTED, b);
811-
j.waitForMessage("Timeout has been exceeded", b); // TODO assertLogContains fails unless a sleep is introduced; possible race condition in waitForCompletion
811+
j.assertLogContains("Timeout has been exceeded", b);
812812
}
813813

814814
@Issue("JENKINS-62014")

src/test/java/org/jenkinsci/plugins/workflow/support/steps/ExecutorStepTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,6 @@ void queueItemAction() throws Throwable {
652652
Queue.Item[] items = Queue.getInstance().getItems();
653653
assertEquals(1, items.length);
654654
assertEquals(p, items[0].task.getOwnerTask());
655-
// // TODO 2.389+ remove cast
656655
assertEquals(b, items[0].task.getOwnerExecutable());
657656
assertEquals(items[0], QueueItemAction.getQueueItem(executorStartNode));
658657

0 commit comments

Comments
 (0)