From 6d61c800ce29ff2317cb131def280217e49af87a Mon Sep 17 00:00:00 2001 From: Vojtech Juranek Date: Tue, 10 Jan 2012 11:13:27 +0100 Subject: [PATCH] Added possibility to delete matrix job with all its sub-builds (configurations) --- .../main/java/hudson/matrix/MatrixBuild.java | 32 ++++++++++++++ .../matrix/MatrixBuild/confirmDeleteAll.jelly | 43 +++++++++++++++++++ .../hudson/matrix/MatrixBuild/delete.jelly | 38 ++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 core/src/main/resources/hudson/matrix/MatrixBuild/confirmDeleteAll.jelly create mode 100644 core/src/main/resources/hudson/matrix/MatrixBuild/delete.jelly diff --git a/core/src/main/java/hudson/matrix/MatrixBuild.java b/core/src/main/java/hudson/matrix/MatrixBuild.java index ecdbd771e8..46f1999f88 100644 --- a/core/src/main/java/hudson/matrix/MatrixBuild.java +++ b/core/src/main/java/hudson/matrix/MatrixBuild.java @@ -52,6 +52,8 @@ import java.util.HashSet; import java.util.List; import java.util.TreeSet; +import javax.servlet.ServletException; + /** * Build of {@link MatrixProject}. * @@ -85,6 +87,36 @@ public class MatrixBuild extends AbstractBuild { return this; } + /** + * Deletes the build and all matrix configurations in this build when the button is pressed. + */ + public void doDoDeleteAll( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { + requirePOST(); + checkPermission(DELETE); + + // We should not simply delete the build if it has been explicitly + // marked to be preserved, or if the build should not be deleted + // due to dependencies! + String why = getWhyKeepLog(); + if (why!=null) { + sendError(hudson.model.Messages.Run_UnableToDelete(toString(),why),req,rsp); + return; + } + + List runs = getRuns(); + for(MatrixRun run : runs){ + why = run.getWhyKeepLog(); + if (why!=null) { + sendError(hudson.model.Messages.Run_UnableToDelete(toString(),why),req,rsp); + return; + } + run.delete(); + } + delete(); + rsp.sendRedirect2(req.getContextPath()+'/' + getParent().getUrl()); + } + + /** * Used by view to render a ball for {@link MatrixRun}. */ diff --git a/core/src/main/resources/hudson/matrix/MatrixBuild/confirmDeleteAll.jelly b/core/src/main/resources/hudson/matrix/MatrixBuild/confirmDeleteAll.jelly new file mode 100644 index 0000000000..3ec6f07388 --- /dev/null +++ b/core/src/main/resources/hudson/matrix/MatrixBuild/confirmDeleteAll.jelly @@ -0,0 +1,43 @@ + + + + + + + + + + + ${%Warning}: ${%cannotMsg(msg)} + + +
+ ${%Are you sure about deleting the build and all configurations in this build?} + + +
+
+
+
diff --git a/core/src/main/resources/hudson/matrix/MatrixBuild/delete.jelly b/core/src/main/resources/hudson/matrix/MatrixBuild/delete.jelly new file mode 100644 index 0000000000..585d20ed89 --- /dev/null +++ b/core/src/main/resources/hudson/matrix/MatrixBuild/delete.jelly @@ -0,0 +1,38 @@ + + + + + + +
+ + +
+ + +
+
\ No newline at end of file -- GitLab