diff --git a/core/src/main/java/hudson/Proc.java b/core/src/main/java/hudson/Proc.java index 10928395601e8a63e33d138e49ff76f78c8f5a5e..b101edcac1a0430c34fa66abdb3ea4a4dfe24dc5 100644 --- a/core/src/main/java/hudson/Proc.java +++ b/core/src/main/java/hudson/Proc.java @@ -50,6 +50,9 @@ public final class Proc { proc.getOutputStream().close(); } + /** + * Waits for the completion of the process. + */ public int join() { try { t1.join(); @@ -62,6 +65,14 @@ public final class Proc { } } + /** + * Terminates the process. + */ + public void kill() { + proc.destroy(); + join(); + } + private static class Copier extends Thread { private final InputStream in; private final OutputStream out; diff --git a/core/src/main/java/hudson/model/Descriptor.java b/core/src/main/java/hudson/model/Descriptor.java index 2782f5979f4ad7c7c021dbacca9f6c511de71f72..413bca248edb72b218e0e1713fd153061d2c5384 100644 --- a/core/src/main/java/hudson/model/Descriptor.java +++ b/core/src/main/java/hudson/model/Descriptor.java @@ -100,6 +100,14 @@ public abstract class Descriptor> { return clazz.isInstance(instance); } + /** + * @deprecated + * As of 1.64. Use {@link #configure(StaplerRequest)}. + */ + public boolean configure( HttpServletRequest req ) throws FormException { + return true; + } + /** * Invoked when the global configuration page is submitted. * @@ -108,8 +116,9 @@ public abstract class Descriptor> { * @return false * to keep the client in the same config page. */ - public boolean configure( HttpServletRequest req ) throws FormException { - return true; + public boolean configure( StaplerRequest req ) throws FormException { + // compatibility + return configure( (HttpServletRequest) req ); } public final String getConfigPage() { diff --git a/core/src/main/java/hudson/model/Project.java b/core/src/main/java/hudson/model/Project.java index 024baa8032593f483820cfd160466d10337817ae..e129ab8584c755ff3b4482fece353380fc1b5e4e 100644 --- a/core/src/main/java/hudson/model/Project.java +++ b/core/src/main/java/hudson/model/Project.java @@ -14,6 +14,8 @@ import hudson.tasks.BuildTrigger; import hudson.tasks.Builder; import hudson.tasks.Fingerprinter; import hudson.tasks.Publisher; +import hudson.tasks.BuildWrapper; +import hudson.tasks.BuildWrappers; import hudson.tasks.test.AbstractTestResultAction; import hudson.triggers.Trigger; import hudson.triggers.Triggers; @@ -68,6 +70,14 @@ public class Project extends Job { */ private List publishers = new Vector(); + /** + * List of active {@link BuildWrapper}s configured for this project. + * + *

+ * Marked as 'transient' for now, so that we can make breaking changes. + */ + private transient List buildWrappers = new Vector(); + /** * {@link Action}s contributed from {@link #triggers}, {@link #builders}, * and {@link #publishers}. @@ -214,6 +224,10 @@ public class Project extends Job { return Descriptor.toMap(publishers); } + public synchronized Map,BuildWrapper> getBuildWrappers() { + return Descriptor.toMap(buildWrappers); + } + private synchronized > void addToList( T item, List collection ) throws IOException { for( int i=0; i { assignedNode = null; } + buildDescribable(req, BuildWrappers.WRAPPERS, buildWrappers, "wrapper"); buildDescribable(req, BuildStep.BUILDERS, builders, "builder"); buildDescribable(req, BuildStep.PUBLISHERS, publishers, "publisher"); diff --git a/core/src/main/java/hudson/scm/CVSSCM.java b/core/src/main/java/hudson/scm/CVSSCM.java index 3c0cb9fedd1603efa221d95f42a4961339332c58..97495100454d5352de6e58df9b5ba106828726e3 100644 --- a/core/src/main/java/hudson/scm/CVSSCM.java +++ b/core/src/main/java/hudson/scm/CVSSCM.java @@ -555,7 +555,7 @@ public class CVSSCM extends AbstractCVSFamilySCM { } - public boolean configure( HttpServletRequest req ) { + public boolean configure( StaplerRequest req ) { setCvspassFile(req.getParameter("cvs_cvspass")); Map browsers = new HashMap(); diff --git a/core/src/main/java/hudson/scm/SubversionSCM.java b/core/src/main/java/hudson/scm/SubversionSCM.java index 36bf52d20b88a036f1ecca2769f67311443db18e..c62213d32fe584d4db4a86f21a0f6f3296414059 100644 --- a/core/src/main/java/hudson/scm/SubversionSCM.java +++ b/core/src/main/java/hudson/scm/SubversionSCM.java @@ -448,7 +448,7 @@ public class SubversionSCM extends AbstractCVSFamilySCM { save(); } - public boolean configure( HttpServletRequest req ) { + public boolean configure( StaplerRequest req ) { svnExe = req.getParameter("svn_exe"); return true; } diff --git a/core/src/main/java/hudson/tasks/Ant.java b/core/src/main/java/hudson/tasks/Ant.java index a09c2dfaabe2d5590e8738edb7c5a948ebbc4f0f..1942e13132910f0fa7732d0ca74977422d460354 100644 --- a/core/src/main/java/hudson/tasks/Ant.java +++ b/core/src/main/java/hudson/tasks/Ant.java @@ -126,7 +126,7 @@ public class Ant extends Builder { return installations; } - public boolean configure(HttpServletRequest req) { + public boolean configure(StaplerRequest req) { boolean r = true; int i; diff --git a/core/src/main/java/hudson/tasks/BuildWrapper.java b/core/src/main/java/hudson/tasks/BuildWrapper.java new file mode 100644 index 0000000000000000000000000000000000000000..0edf5dea15304dbaf6332e70083f0d6a003f60ad --- /dev/null +++ b/core/src/main/java/hudson/tasks/BuildWrapper.java @@ -0,0 +1,78 @@ +package hudson.tasks; + +import hudson.ExtensionPoint; +import hudson.Launcher; +import hudson.model.Build; +import hudson.model.BuildListener; +import hudson.model.Describable; +import hudson.model.Project; + +import java.util.Map; +import java.io.IOException; + +/** + * Pluggability point for performing pre/post actions for the build process. + * + *

+ * STILL EXPERIMENTAL. SUBJECT TO CHANGE + * + *

+ * This extension point enables a plugin to set up / tear down additional + * services needed to perform a build, such as setting up local X display, + * or launching and stopping application servers for testing. + * + *

+ * An instance of {@link BuildWrapper} is associated with a {@link Project} + * with configuration information as its state. An instance is persisted + * along with {@link Project}. + * + *

+ * The {@link #setUp(Build, BuildListener)} method is invoked for each build. + * + * @author Kohsuke Kawaguchi + */ +public abstract class BuildWrapper implements ExtensionPoint, Describable { + /** + * Represents the environment set up by {@link BuildWrapper#setUp(Build, BuildListener)}. + * + *

+ * It is expected that the subclasses of {@link BuildWrapper} extends this + * class and implements its own semantics. + */ + public class Environment { + /** + * Adds environmental variables for the builds to the given map. + */ + public void buildEnvVars(Map env) { + // no-op by default + } + + /** + * Runs after the {@link Builder} completes, and performs a tear down. + * + *

+ * This method is invoked even when the build failed, so that the + * clean up operation can be performed regardless of the build result + * (for example, you'll want to stop application server even if a build + * fails.) + * + * @return + * true if the build can continue, false if there was an error + * and the build needs to be aborted. + */ + public boolean tearDown( Build build, BuildListener listener ) throws IOException { + return true; + } + } + + /** + * Runs before the {@link Builder} runs, and performs a set up. + * + * @return + * non-null if the build can continue, null if there was an error + * and the build needs to be aborted. + */ + public Environment setUp( Build build, Launcher launcher, BuildListener listener ) throws IOException { + return new Environment(); + } +} diff --git a/core/src/main/java/hudson/tasks/BuildWrappers.java b/core/src/main/java/hudson/tasks/BuildWrappers.java new file mode 100644 index 0000000000000000000000000000000000000000..72e8e278059d61b9893e88a10f24e5a2f13e134b --- /dev/null +++ b/core/src/main/java/hudson/tasks/BuildWrappers.java @@ -0,0 +1,15 @@ +package hudson.tasks; + +import hudson.model.Descriptor; + +import java.util.List; + +/** + * List of all installed {@link BuildWrapper}. + * + * @author Kohsuke Kawaguchi + */ +public class BuildWrappers { + public static final List> WRAPPERS = Descriptor.toList( + ); +} diff --git a/core/src/main/java/hudson/tasks/Mailer.java b/core/src/main/java/hudson/tasks/Mailer.java index 8fe4323ce9d636b1392aad8ace77c8c47ba64699..9698409c2d2ca45b8d0a5fe4a478f4a1f479255e 100644 --- a/core/src/main/java/hudson/tasks/Mailer.java +++ b/core/src/main/java/hudson/tasks/Mailer.java @@ -336,7 +336,7 @@ public class Mailer extends Publisher { }; } - public boolean configure(HttpServletRequest req) throws FormException { + public boolean configure(StaplerRequest req) throws FormException { // this code is brain dead smtpHost = nullify(req.getParameter("mailer_smtp_server")); adminAddress = req.getParameter("mailer_admin_address"); diff --git a/core/src/main/java/hudson/tasks/Maven.java b/core/src/main/java/hudson/tasks/Maven.java index 73d2b6d245760a63ce3d3a0a179db1bd09ffb8cc..bebb50d3560d4f7f1701a7388a294bbaa093ef81 100644 --- a/core/src/main/java/hudson/tasks/Maven.java +++ b/core/src/main/java/hudson/tasks/Maven.java @@ -128,7 +128,7 @@ public class Maven extends Builder { return installations; } - public boolean configure(HttpServletRequest req) { + public boolean configure(StaplerRequest req) { boolean r = true; int i; diff --git a/core/src/main/java/hudson/tasks/Shell.java b/core/src/main/java/hudson/tasks/Shell.java index c845337b2a418c6fe8af04586785413822b89371..cf88cd0639563b830ac6e8ece8ce69437f5a96b9 100644 --- a/core/src/main/java/hudson/tasks/Shell.java +++ b/core/src/main/java/hudson/tasks/Shell.java @@ -131,7 +131,7 @@ public class Shell extends Builder { return new Shell(req.getParameter("shell")); } - public boolean configure( HttpServletRequest req ) { + public boolean configure( StaplerRequest req ) { setShell(req.getParameter("shell")); return true; } diff --git a/core/src/main/java/hudson/triggers/SCMTrigger.java b/core/src/main/java/hudson/triggers/SCMTrigger.java index 3f80bc8a0382c42a64e0f3ed82d76ae443e1f306..d4f2c6f766d3182d3d0e8f0d768489856a63f2cb 100644 --- a/core/src/main/java/hudson/triggers/SCMTrigger.java +++ b/core/src/main/java/hudson/triggers/SCMTrigger.java @@ -193,7 +193,7 @@ public class SCMTrigger extends Trigger { old.shutdown(); } - public boolean configure(HttpServletRequest req) throws FormException { + public boolean configure(StaplerRequest req) throws FormException { String t = req.getParameter("poll_scm_threads"); if(t==null || t.length()==0) setPollingThreadCount(0); diff --git a/core/src/main/java/hudson/triggers/Triggers.java b/core/src/main/java/hudson/triggers/Triggers.java index 7324db70d6e498e56b633e0440e3ca19840dd848..b678301f4712511b658283dd3bc25585e8f02832 100644 --- a/core/src/main/java/hudson/triggers/Triggers.java +++ b/core/src/main/java/hudson/triggers/Triggers.java @@ -5,12 +5,11 @@ import hudson.model.Descriptor; import java.util.List; /** + * List of all installed {@link Trigger}s. + * * @author Kohsuke Kawaguchi */ public class Triggers { - /** - * List of all installed {@link Trigger}s. - */ public static final List> TRIGGERS = Descriptor.toList( SCMTrigger.DESCRIPTOR, TimerTrigger.DESCRIPTOR diff --git a/core/src/main/resources/hudson/model/Project/configure-entries.jelly b/core/src/main/resources/hudson/model/Project/configure-entries.jelly index c937e11b451901f413c091ec9fef67a332c5d0d3..4b3480208e77e0655f79450e95efe91d66f0a410 100644 --- a/core/src/main/resources/hudson/model/Project/configure-entries.jelly +++ b/core/src/main/resources/hudson/model/Project/configure-entries.jelly @@ -95,6 +95,16 @@ + + + + + + +