提交 3dd283c4 编写于 作者: J jglick

[FIXED HUDSON-3502] Maven builds were not correctly using build wrappers.

Module set builds were running wrappers but ignoring any environment variables they tried to set.
Individual module builds (e.g. "Run in parallel" checked, or just click Build Now on a module) were ignoring wrappers altogether.
Either way, $DISPLAY was not being set when the XVNC plugin was used.
Note: there is a certain amount of code duplication in the various doRun implementations which could perhaps be factored out somewhere.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@17323 71c3de6d-444a-0410-be80-ed276b4c234a
上级 cc68d4a1
......@@ -35,9 +35,11 @@ import hudson.model.Hudson;
import hudson.model.Result;
import hudson.model.Run;
import hudson.model.Cause.UpstreamCause;
import hudson.model.Environment;
import hudson.remoting.Channel;
import hudson.scm.ChangeLogSet;
import hudson.scm.ChangeLogSet.Entry;
import hudson.tasks.BuildWrapper;
import hudson.util.ArgumentListBuilder;
import org.apache.maven.BuildFailureException;
import org.apache.maven.execution.MavenSession;
......@@ -458,17 +460,26 @@ public class MavenBuild extends AbstractBuild<MavenModule,MavenBuild> {
protected Result doRun(BuildListener listener) throws Exception {
// pick up a list of reporters to run
reporters = getProject().createReporters();
MavenModuleSet mms = getProject().getParent();
if(debug)
listener.getLogger().println("Reporters="+reporters);
EnvVars envVars = getEnvironment();
buildEnvironments = new ArrayList<Environment>();
for (BuildWrapper w : mms.getBuildWrappers()) {
BuildWrapper.Environment e = w.setUp(MavenBuild.this, launcher, listener);
if (e == null) {
return Result.FAILURE;
}
buildEnvironments.add(e);
}
EnvVars envVars = getEnvironment(); // buildEnvironments should be set up first
ProcessCache.MavenProcess process = mavenProcessCache.get(launcher.getChannel(), listener,
new MavenProcessFactory(getParent().getParent(),launcher,envVars,null));
ArgumentListBuilder margs = new ArgumentListBuilder();
margs.add("-N").add("-B");
MavenModuleSet mms = project.getParent();
if(mms.usesPrivateRepository())
// use the per-project repository. should it be per-module? But that would cost too much in terms of disk
// the workspace must be on this node, so getRemote() is safe.
......@@ -490,6 +501,10 @@ public class MavenBuild extends AbstractBuild<MavenModule,MavenBuild> {
} finally {
if(normalExit) process.recycle();
else process.discard();
for (int i = buildEnvironments.size() - 1; i >= 0; i--) {
buildEnvironments.get(i).tearDown(MavenBuild.this, listener);
buildEnvironments = null;
}
}
}
......
......@@ -330,10 +330,11 @@ public final class MavenModuleSetBuild extends AbstractBuild<MavenModuleSet,Mave
buildEnvironments = new ArrayList<Environment>();
for( BuildWrapper w : wrappers) {
BuildWrapper.Environment e = w.setUp((AbstractBuild)MavenModuleSetBuild.this, launcher, listener);
BuildWrapper.Environment e = w.setUp(MavenModuleSetBuild.this, launcher, listener);
if(e==null)
return Result.FAILURE;
buildEnvironments.add(e);
e.buildEnvVars(envVars); // #3502: too late for getEnvironment to do this
}
if(!preBuild(listener, project.getPublishers()))
......@@ -380,7 +381,7 @@ public final class MavenModuleSetBuild extends AbstractBuild<MavenModuleSet,Mave
// tear down in reverse order
for( int i=buildEnvironments.size()-1; i>=0; i-- )
buildEnvironments.get(i)
.tearDown((AbstractBuild)MavenModuleSetBuild.this, listener);
.tearDown(MavenModuleSetBuild.this, listener);
buildEnvironments = null;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册