Skip to content
Permalink
Browse files

[FIXED JENKINS-27152] Keep control files outside of the workspace.

  • Loading branch information
jglick committed Feb 20, 2016
1 parent 38fc470 commit 85be167e1efbd0ef2e813f197c3ab7ba5031cbca
@@ -31,6 +31,7 @@
import hudson.model.TaskListener;
import hudson.remoting.RemoteOutputStream;
import hudson.remoting.VirtualChannel;
import hudson.slaves.WorkspaceList;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
@@ -89,6 +90,7 @@ protected FileMonitoringController doLaunch(FilePath workspace, Launcher launche

protected FileMonitoringController(FilePath ws) throws IOException, InterruptedException {
// can't keep ws reference because Controller is expected to be serializable
ws.mkdirs();
controlDir(ws).mkdirs();
}

@@ -160,7 +162,12 @@ protected FileMonitoringController(FilePath ws) throws IOException, InterruptedE
* Directory in which this controller can place files.
*/
public FilePath controlDir(FilePath ws) {
return ws.child(".jenkins-" + id);
return tempDir(ws).child("durable-" + id);
}

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

/**
@@ -37,7 +37,9 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.util.Collections;
import static org.hamcrest.Matchers.containsString;
import org.junit.Before;
import org.jvnet.hudson.test.Issue;

public class BourneShellScriptTest extends Assert {

@@ -53,7 +55,7 @@

@Before public void vars() {
listener = StreamTaskListener.fromStdout();
ws = j.jenkins.getRootPath();
ws = j.jenkins.getRootPath().child("ws");
launcher = j.jenkins.createLauncher(listener);
}

@@ -107,4 +109,17 @@ public void smokeTest() throws Exception {
c.cleanup(ws);
}

@Issue("JENKINS-27152")
@Test public void cleanWorkspace() throws Exception {
Controller c = new BourneShellScript("touch stuff && echo ---`ls -1a`---").launch(new EnvVars(), ws, launcher, listener);
while (c.exitStatus(ws, launcher) == null) {
Thread.sleep(100);
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
c.writeLog(ws, baos);
assertEquals(0, c.exitStatus(ws, launcher).intValue());
assertThat(baos.toString(), containsString("---. .. stuff---"));
c.cleanup(ws);
}

}

0 comments on commit 85be167

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