Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to skip removal of container after docker stop via the org.jenkinsci.plugins.docker.workflow.client.DockerClient.SKIP_RM_ON_STOPproperty #189

Merged
merged 1 commit into from
Aug 28, 2020
Merged
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 @@ -76,6 +76,13 @@ public class DockerClient {
@Restricted(NoExternalUse.class)
public static int CLIENT_TIMEOUT = Integer.getInteger(DockerClient.class.getName() + ".CLIENT_TIMEOUT", 180); // TODO 2.4+ SystemProperties

/**
* Skip removal of container after a container has been stopped.
*/
@SuppressFBWarnings(value="MS_SHOULD_BE_FINAL", justification="mutable for scripts")
@Restricted(NoExternalUse.class)
public static boolean SKIP_RM_ON_STOP = Boolean.getBoolean(DockerClient.class.getName() + ".SKIP_RM_ON_STOP");

// e.g. 2015-04-09T13:40:21.981801679Z
public static final String DOCKER_DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";

Expand Down Expand Up @@ -160,7 +167,8 @@ public List<String> listProcess(@Nonnull EnvVars launchEnv, @Nonnull String cont
* Stop a container.
*
* <p>
* Also removes ({@link #rm(EnvVars, String)}) the container.
* Also removes ({@link #rm(EnvVars, String)}) the container if property
* SKIP_RM_ON_STOP is unset or equals false.
*
* @param launchEnv Docker client launch environment.
* @param containerId The container ID.
Expand All @@ -170,7 +178,9 @@ public void stop(@Nonnull EnvVars launchEnv, @Nonnull String containerId) throws
if (result.getStatus() != 0) {
throw new IOException(String.format("Failed to kill container '%s'.", containerId));
}
rm(launchEnv, containerId);
if (!SKIP_RM_ON_STOP) {
rm(launchEnv, containerId);
}
}

/**
Expand Down