From 029f6715f4cf2b2a245bb3236c41bdec96be560f Mon Sep 17 00:00:00 2001 From: kohsuke Date: Fri, 10 Jul 2009 17:37:06 +0000 Subject: [PATCH] [FIXED HUDSON-3087] Purging workspace in Matrix job should purge all configuration workspaces, too. In 1.316. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@19589 71c3de6d-444a-0410-be80-ed276b4c234a --- core/pom.xml | 2 +- .../java/hudson/matrix/MatrixProject.java | 12 ++++++++++ .../java/hudson/model/AbstractProject.java | 22 ++++++++++--------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 518df5bf48..3a718d372d 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -319,7 +319,7 @@ THE SOFTWARE. org.kohsuke.stapler stapler-jelly - 1.106 + 1.107 dom4j diff --git a/core/src/main/java/hudson/matrix/MatrixProject.java b/core/src/main/java/hudson/matrix/MatrixProject.java index c83786fa4d..97cffe130c 100644 --- a/core/src/main/java/hudson/matrix/MatrixProject.java +++ b/core/src/main/java/hudson/matrix/MatrixProject.java @@ -78,6 +78,7 @@ import net.sf.json.JSONObject; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; +import org.kohsuke.stapler.HttpResponse; /** * {@link Job} that allows you to run multiple different configurations @@ -542,6 +543,17 @@ public class MatrixProject extends AbstractProject im rebuildConfigurations(); } + /** + * Also delete all the workspaces of the configuration, too. + */ + @Override + public HttpResponse doDoWipeOutWorkspace() throws IOException, ServletException, InterruptedException { + HttpResponse rsp = super.doDoWipeOutWorkspace(); + for (MatrixConfiguration c : configurations.values()) + c.doDoWipeOutWorkspace(); + return rsp; + } + public DescriptorImpl getDescriptor() { return DESCRIPTOR; } diff --git a/core/src/main/java/hudson/model/AbstractProject.java b/core/src/main/java/hudson/model/AbstractProject.java index 4a96fd5234..9ac065a319 100644 --- a/core/src/main/java/hudson/model/AbstractProject.java +++ b/core/src/main/java/hudson/model/AbstractProject.java @@ -61,6 +61,9 @@ import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; import org.kohsuke.stapler.export.Exported; import org.kohsuke.stapler.QueryParameter; +import org.kohsuke.stapler.HttpResponse; +import org.kohsuke.stapler.HttpRedirect; +import org.kohsuke.stapler.ForwardToView; import javax.servlet.ServletException; @@ -1251,29 +1254,28 @@ public abstract class AbstractProject

,R extends A /** * Wipes out the workspace. */ - public void doDoWipeOutWorkspace(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, InterruptedException { + public HttpResponse doDoWipeOutWorkspace() throws IOException, ServletException, InterruptedException { checkPermission(BUILD); if (getScm().processWorkspaceBeforeDeletion(this, getWorkspace(), null)) { getWorkspace().deleteRecursive(); - rsp.sendRedirect2("."); - } - // If we get here, that means the SCM blocked the workspace deletion. - else { - req.getView(this, "wipeOutWorkspaceBlocked.jelly").forward(req, rsp); + return new HttpRedirect("."); + } else { + // If we get here, that means the SCM blocked the workspace deletion. + return new ForwardToView(this,"wipeOutWorkspaceBlocked.jelly"); } } - public void doDisable(StaplerResponse rsp) throws IOException, ServletException { + public HttpResponse doDisable() throws IOException, ServletException { requirePOST(); checkPermission(CONFIGURE); makeDisabled(true); - rsp.sendRedirect2("."); + return new HttpRedirect("."); } - public void doEnable(StaplerResponse rsp) throws IOException, ServletException { + public HttpResponse doEnable() throws IOException, ServletException { checkPermission(CONFIGURE); makeDisabled(false); - rsp.sendRedirect2("."); + return new HttpRedirect("."); } /**