Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
If the user asks to stop a shell step twice, force it to die.
Works around bugs like JENKINS-25678 which would otherwise make the flow unkillable.
  • Loading branch information
jglick committed Nov 19, 2014
1 parent 90a4f60 commit 9901d51bee1eae473ba9f57810643b8e8e4cfe79
Showing with 11 additions and 4 deletions.
  1. +11 −4 ...le-task-step/src/main/java/org/jenkinsci/plugins/workflow/steps/durable_task/DurableTaskStep.java
@@ -82,6 +82,7 @@ public static final class Execution extends AbstractStepExecutionImpl implements
@StepContextParameter private transient Launcher launcher;
@StepContextParameter private transient TaskListener listener;
private transient long recurrencePeriod;
private transient int stopAttempt;
private Controller controller;
private String node;
private String remote;
@@ -140,9 +141,15 @@ public static final class Execution extends AbstractStepExecutionImpl implements
}

@Override public void stop(Throwable cause) throws Exception {
FilePath workspace = getWorkspace();
if (workspace != null) {
controller.stop(workspace);
try {
FilePath workspace = getWorkspace();
if (workspace != null) {
controller.stop(workspace);
}
} finally {
if (stopAttempt++ == 1) { // second attempt
getContext().onFailure(cause);
}
}
}

@@ -151,7 +158,7 @@ public static final class Execution extends AbstractStepExecutionImpl implements
try {
check();
} finally {
if (recurrencePeriod > 0) {
if (recurrencePeriod > 0 && stopAttempt < 2) {
Timer.get().schedule(this, recurrencePeriod, TimeUnit.MILLISECONDS);
}
}

0 comments on commit 9901d51

Please sign in to comment.