From 307bfc17385c14aefcb623ccc3e7144e4f01e2a3 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Fri, 26 Feb 2016 15:52:58 -0500 Subject: [PATCH 01/25] [JENKINS-27152] Introduce common API WorkspaceList.tempDir. --- .../hudson/model/WorkspaceCleanupThread.java | 2 ++ .../java/hudson/slaves/WorkspaceList.java | 20 +++++++++++++++++++ .../model/WorkspaceCleanupThreadTest.java | 14 +++++++++++++ 3 files changed, 36 insertions(+) diff --git a/core/src/main/java/hudson/model/WorkspaceCleanupThread.java b/core/src/main/java/hudson/model/WorkspaceCleanupThread.java index 9e83e143e5..a7a606b476 100644 --- a/core/src/main/java/hudson/model/WorkspaceCleanupThread.java +++ b/core/src/main/java/hudson/model/WorkspaceCleanupThread.java @@ -27,6 +27,7 @@ import hudson.Extension; import hudson.ExtensionList; import hudson.FilePath; import hudson.Util; +import hudson.slaves.WorkspaceList; import java.io.IOException; import java.util.ArrayList; import java.util.Date; @@ -89,6 +90,7 @@ public class WorkspaceCleanupThread extends AsyncPeriodicWork { listener.getLogger().println("Deleting " + ws + " on " + node.getDisplayName()); try { ws.deleteRecursive(); + WorkspaceList.tempDir(ws).deleteRecursive(); } catch (IOException x) { x.printStackTrace(listener.error("Failed to delete " + ws + " on " + node.getDisplayName())); } catch (InterruptedException x) { diff --git a/core/src/main/java/hudson/slaves/WorkspaceList.java b/core/src/main/java/hudson/slaves/WorkspaceList.java index a344b45aac..98347b2ab4 100644 --- a/core/src/main/java/hudson/slaves/WorkspaceList.java +++ b/core/src/main/java/hudson/slaves/WorkspaceList.java @@ -26,6 +26,7 @@ package hudson.slaves; import hudson.FilePath; import hudson.Functions; import hudson.model.Computer; +import hudson.model.DirectoryBrowserSupport; import java.io.Closeable; import java.util.Date; @@ -283,6 +284,25 @@ public final class WorkspaceList { }; } + /** + * Locates a conventional temporary directory to be associated with a workspace. + *

This directory is suitable for temporary files to be deleted later in the course of a build, + * or caches and local repositories which should persist across builds done in the same workspace. + * (If multiple workspaces are present for a single job built concurrently, via {@link #allocate(FilePath)}, each will get its own temporary directory.) + *

It may also be used for security-sensitive files which {@link DirectoryBrowserSupport} ought not serve, + * acknowledging that these will be readable by builds of other jobs done on the same node. + *

Each plugin using this directory is responsible for specifying sufficiently unique subdirectory/file names. + * {@link FilePath#createTempFile} may be used for this purpose if desired. + *

The resulting directory may not exist; you may call {@link FilePath#mkdirs} on it if you need it to. + * It may be deleted alongside the workspace itself during cleanup actions. + * @param ws a directory such as a build workspace + * @return a sibling directory, for example {@code …/something@tmp} for {@code …/something} + * @since TODO + */ + public static FilePath tempDir(FilePath ws) { + return ws.sibling(ws.getName() + COMBINATOR + "tmp"); + } + private static final Logger LOGGER = Logger.getLogger(WorkspaceList.class.getName()); /** diff --git a/test/src/test/java/hudson/model/WorkspaceCleanupThreadTest.java b/test/src/test/java/hudson/model/WorkspaceCleanupThreadTest.java index 28d7dd04e1..0971276179 100644 --- a/test/src/test/java/hudson/model/WorkspaceCleanupThreadTest.java +++ b/test/src/test/java/hudson/model/WorkspaceCleanupThreadTest.java @@ -28,6 +28,7 @@ import hudson.FilePath; import hudson.remoting.VirtualChannel; import hudson.scm.NullSCM; import hudson.slaves.DumbSlave; +import hudson.slaves.WorkspaceList; import hudson.util.StreamTaskListener; import java.io.File; @@ -180,6 +181,19 @@ public class WorkspaceCleanupThreadTest { assertFalse(ws.exists()); } + @Issue("JENKINS-27152") + @Test + public void deleteTemporaryDirectory() throws Exception { + FreeStyleProject p = r.createFreeStyleProject(); + FilePath ws = createOldWorkspaceOn(r.jenkins, p); + FilePath tmp = WorkspaceList.tempDir(ws); + tmp.child("stuff").write("content", null); + createOldWorkspaceOn(r.createOnlineSlave(), p); + performCleanup(); + assertFalse(ws.exists()); + assertFalse("temporary directory should be cleaned up as well", tmp.exists()); + } + private FilePath createOldWorkspaceOn(Node slave, FreeStyleProject p) throws Exception { p.setAssignedNode(slave); FreeStyleBuild b1 = r.assertBuildStatusSuccess(p.scheduleBuild2(0)); From 2d83d39ce59b27787b8879b9270493adbf586f00 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sun, 28 Feb 2016 21:51:14 -0800 Subject: [PATCH 02/25] [maven-release-plugin] prepare release jenkins-1.651 --- cli/pom.xml | 2 +- core/pom.xml | 2 +- pom.xml | 4 ++-- test/pom.xml | 2 +- war/pom.xml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cli/pom.xml b/cli/pom.xml index 057ede78e7..0a4446727d 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -5,7 +5,7 @@ org.jenkins-ci.main pom - 1.651-SNAPSHOT + 1.651 cli diff --git a/core/pom.xml b/core/pom.xml index 5cebd6c25a..4852592cab 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -29,7 +29,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.651-SNAPSHOT + 1.651 jenkins-core diff --git a/pom.xml b/pom.xml index fa197c2030..c9af50a84a 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.651-SNAPSHOT + 1.651 pom Jenkins main module @@ -58,7 +58,7 @@ THE SOFTWARE. scm:git:git://github.com/jenkinsci/jenkins.git scm:git:ssh://git@github.com/jenkinsci/jenkins.git https://github.com/jenkinsci/jenkins - HEAD + jenkins-1.651 diff --git a/test/pom.xml b/test/pom.xml index dd1f50cc5b..0430e344e5 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.651-SNAPSHOT + 1.651 test diff --git a/war/pom.xml b/war/pom.xml index c54bcf7d00..acaf96d382 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.651-SNAPSHOT + 1.651 jenkins-war From 0a866f5727f5eb25bf895a7a60ce9c199cda0645 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sun, 28 Feb 2016 21:51:15 -0800 Subject: [PATCH 03/25] [maven-release-plugin] prepare for next development iteration --- cli/pom.xml | 2 +- core/pom.xml | 2 +- pom.xml | 4 ++-- test/pom.xml | 2 +- war/pom.xml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cli/pom.xml b/cli/pom.xml index 0a4446727d..60ff50f0c5 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -5,7 +5,7 @@ org.jenkins-ci.main pom - 1.651 + 1.652-SNAPSHOT cli diff --git a/core/pom.xml b/core/pom.xml index 4852592cab..381c485acc 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -29,7 +29,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.651 + 1.652-SNAPSHOT jenkins-core diff --git a/pom.xml b/pom.xml index c9af50a84a..47537cd874 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.651 + 1.652-SNAPSHOT pom Jenkins main module @@ -58,7 +58,7 @@ THE SOFTWARE. scm:git:git://github.com/jenkinsci/jenkins.git scm:git:ssh://git@github.com/jenkinsci/jenkins.git https://github.com/jenkinsci/jenkins - jenkins-1.651 + HEAD diff --git a/test/pom.xml b/test/pom.xml index 0430e344e5..7767a50fa6 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.651 + 1.652-SNAPSHOT test diff --git a/war/pom.xml b/war/pom.xml index acaf96d382..0486d6baec 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -28,7 +28,7 @@ THE SOFTWARE. org.jenkins-ci.main pom - 1.651 + 1.652-SNAPSHOT jenkins-war From 40c1f29dd2d8c6ef0fe1bf149dc60a7655ffbad3 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sun, 28 Feb 2016 21:58:46 -0800 Subject: [PATCH 04/25] updated changelog for release --- changelog.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/changelog.html b/changelog.html index 7317e898ad..1a859089d1 100644 --- a/changelog.html +++ b/changelog.html @@ -54,12 +54,16 @@ Upcoming changes

+

What's new in 1.651 (2016/02/28)

-

What's new in 1.650 (2016/02/24)