提交 856d15e4 编写于 作者: K kohsuke

- modified to use StaplerRequest, instead of HttpServletRequest.

- added BuildWrapper class for implementing #158. still very much experimental.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@1192 71c3de6d-444a-0410-be80-ed276b4c234a
上级 dcf56cbb
......@@ -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;
......
......@@ -100,6 +100,14 @@ public abstract class Descriptor<T extends Describable<T>> {
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<T extends Describable<T>> {
* @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() {
......
......@@ -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<Project,Build> {
*/
private List<Publisher> publishers = new Vector<Publisher>();
/**
* List of active {@link BuildWrapper}s configured for this project.
*
* <p>
* Marked as 'transient' for now, so that we can make breaking changes.
*/
private transient List<BuildWrapper> buildWrappers = new Vector<BuildWrapper>();
/**
* {@link Action}s contributed from {@link #triggers}, {@link #builders},
* and {@link #publishers}.
......@@ -214,6 +224,10 @@ public class Project extends Job<Project,Build> {
return Descriptor.toMap(publishers);
}
public synchronized Map<Descriptor<BuildWrapper>,BuildWrapper> getBuildWrappers() {
return Descriptor.toMap(buildWrappers);
}
private synchronized <T extends Describable<T>>
void addToList( T item, List<T> collection ) throws IOException {
for( int i=0; i<collection.size(); i++ ) {
......@@ -533,6 +547,7 @@ public class Project extends Job<Project,Build> {
assignedNode = null;
}
buildDescribable(req, BuildWrappers.WRAPPERS, buildWrappers, "wrapper");
buildDescribable(req, BuildStep.BUILDERS, builders, "builder");
buildDescribable(req, BuildStep.PUBLISHERS, publishers, "publisher");
......
......@@ -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<String,RepositoryBrowser> browsers = new HashMap<String, RepositoryBrowser>();
......
......@@ -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;
}
......
......@@ -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;
......
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.
*
* <p>
* <b>STILL EXPERIMENTAL. SUBJECT TO CHANGE</b>
*
* <p>
* 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.
*
* <p>
* 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}.
*
* <p>
* The {@link #setUp(Build, BuildListener)} method is invoked for each build.
*
* @author Kohsuke Kawaguchi
*/
public abstract class BuildWrapper implements ExtensionPoint, Describable<BuildWrapper> {
/**
* Represents the environment set up by {@link BuildWrapper#setUp(Build, BuildListener)}.
*
* <p>
* 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<String,String> env) {
// no-op by default
}
/**
* Runs after the {@link Builder} completes, and performs a tear down.
*
* <p>
* 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();
}
}
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<Descriptor<BuildWrapper>> WRAPPERS = Descriptor.toList(
);
}
......@@ -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");
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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<Descriptor<Trigger>> TRIGGERS = Descriptor.toList(
SCMTrigger.DESCRIPTOR,
TimerTrigger.DESCRIPTOR
......
......@@ -95,6 +95,16 @@
</f:descriptorList>
<!-- build wrapper config pane -->
<j:getStatic var="wrappers" className="hudson.tasks.BuildWrappers" field="WRAPPERS" />
<j:if test="${!empty(wrappers)}">
<f:descriptorList title="Build Environment"
descriptors="${wrappers}"
instances="${it.buildWrappers}"
varName="wrapper" />
</j:if>
<!-- build config pane -->
<j:getStatic var="builders" className="hudson.tasks.BuildStep" field="BUILDERS" />
<f:descriptorList title="Build"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册