Skip to content
Permalink
Browse files

[JENKINS-27152] Expect to mount workspace@tmp directory.

  • Loading branch information
jglick committed Feb 20, 2016
1 parent d78368d commit 8832083218f687d9d04ba238c99bb1f9a048cc06
Showing with 12 additions and 2 deletions.
  1. +12 −2 src/main/java/org/jenkinsci/plugins/docker/workflow/WithContainerStep.java
@@ -37,13 +37,13 @@
import hudson.model.Node;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.slaves.WorkspaceList;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.Serializable;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -53,6 +53,7 @@
import javax.annotation.Nonnull;

import hudson.util.VersionNumber;
import java.util.LinkedHashMap;
import org.jenkinsci.plugins.docker.commons.fingerprint.DockerFingerprints;
import org.jenkinsci.plugins.workflow.steps.AbstractStepDescriptorImpl;
import org.jenkinsci.plugins.workflow.steps.AbstractStepExecutionImpl;
@@ -135,7 +136,11 @@ private static void destroy(String container, Launcher launcher, Node node, EnvV
listener.error("Failed to parse docker version. Please note there is a minimum docker version requirement of v1.3.");
}

container = dockerClient.run(env, step.image, step.args, ws, Collections.singletonMap(ws, ws), envReduced, dockerClient.whoAmI(), /* expected to hang until killed */ "cat");
Map<String,String> volumes = new LinkedHashMap<String,String>();
volumes.put(ws, ws);
String tmp = tempDir(workspace).getRemote();
volumes.put(tmp, tmp);
container = dockerClient.run(env, step.image, step.args, ws, volumes, envReduced, dockerClient.whoAmI(), /* expected to hang until killed */ "cat");
DockerFingerprints.addRunFacet(dockerClient.getContainerRecord(env, container), run);
ImageAction.add(step.image, run);
getContext().newBodyInvoker().
@@ -145,6 +150,11 @@ private static void destroy(String container, Launcher launcher, Node node, EnvV
return false;
}

// TODO move to WorkspaceList
private static FilePath tempDir(FilePath ws) {
return ws.sibling(ws.getName() + System.getProperty(WorkspaceList.class.getName(), "@") + "tmp");
}

@Override public void stop(Throwable cause) throws Exception {
if (container != null) {
destroy(container, launcher, getContext().get(Node.class), env, toolName);

0 comments on commit 8832083

Please sign in to comment.
You can’t perform that action at this time.