Skip to content

Commit 129a2d7

Browse files
authored
Merge pull request #260 from jglick/null-launcher
Do not pass a null `Launcher` to `DockerClient`
2 parents 0617d9d + 7777007 commit 129a2d7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/java/org/jenkinsci/plugins/docker/workflow/WithContainerStep.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public String getToolName() {
107107
this.toolName = Util.fixEmpty(toolName);
108108
}
109109

110-
private static void destroy(String container, Launcher launcher, Node node, EnvVars launcherEnv, String toolName) throws Exception {
110+
private static void destroy(String container, @NonNull Launcher launcher, Node node, EnvVars launcherEnv, String toolName) throws Exception {
111111
new DockerClient(launcher, node, toolName).stop(launcherEnv, container);
112112
}
113113

@@ -410,7 +410,10 @@ private static class Callback extends BodyExecutionCallback.TailCall {
410410
}
411411

412412
@Override protected void finished(StepContext context) throws Exception {
413-
destroy(container, context.get(Launcher.class), context.get(Node.class), context.get(EnvVars.class), toolName);
413+
Launcher launcher = context.get(Launcher.class);
414+
if (launcher != null) {
415+
destroy(container, launcher, context.get(Node.class), context.get(EnvVars.class), toolName);
416+
}
414417
}
415418

416419
}

0 commit comments

Comments
 (0)