Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-27152] Expect to mount workspace@tmp directory.
  • Loading branch information
jglick committed Feb 20, 2016
1 parent d78368d commit 8832083
Showing 1 changed file with 12 additions and 2 deletions.
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -135,7 +136,11 @@ public static class Execution extends AbstractStepExecutionImpl {
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().
Expand All @@ -145,6 +150,11 @@ public static class Execution extends AbstractStepExecutionImpl {
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);
Expand Down

0 comments on commit 8832083

Please sign in to comment.