Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
If the user asks to stop a shell step twice, force it to die.
Browse files Browse the repository at this point in the history
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 9901d51
Showing 1 changed file with 11 additions and 4 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
}

Expand All @@ -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);
}
}
Expand Down

0 comments on commit 9901d51

Please sign in to comment.