提交 36040b9a 编写于 作者: K kohsuke

[FIXED HUDSON-4080] Node variables not passed through to Maven jobs. In 1.335.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@23695 71c3de6d-444a-0410-be80-ed276b4c234a
上级 0dd593f9
......@@ -43,6 +43,7 @@ import hudson.model.SCMedItem;
import hudson.model.Saveable;
import hudson.model.TopLevelItem;
import hudson.model.ResourceController;
import hudson.model.BuildableItemWithBuildWrappers;
import hudson.model.Queue.FlyweightTask;
import hudson.model.Descriptor.FormException;
import hudson.tasks.BuildStep;
......@@ -90,7 +91,7 @@ import org.kohsuke.stapler.QueryParameter;
*
* @author Kohsuke Kawaguchi
*/
public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> implements TopLevelItem, SCMedItem, ItemGroup<MatrixConfiguration>, Saveable, FlyweightTask {
public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> implements TopLevelItem, SCMedItem, ItemGroup<MatrixConfiguration>, Saveable, FlyweightTask, BuildableItemWithBuildWrappers {
/**
* Other configuration axes.
*
......@@ -511,6 +512,10 @@ public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> im
return publishers;
}
public DescribableList<BuildWrapper, Descriptor<BuildWrapper>> getBuildWrappersList() {
return buildWrappers;
}
public Map<Descriptor<BuildWrapper>,BuildWrapper> getBuildWrappers() {
return buildWrappers.toMap();
}
......
......@@ -29,6 +29,7 @@ import hudson.Launcher;
import hudson.Util;
import hudson.FilePath;
import hudson.slaves.WorkspaceList;
import hudson.slaves.NodeProperty;
import hudson.slaves.WorkspaceList.Lease;
import hudson.matrix.MatrixConfiguration;
import hudson.model.Fingerprint.BuildPtr;
......@@ -413,7 +414,31 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
* Always non-null. Connected to the main build output.
*/
protected Launcher createLauncher(BuildListener listener) throws IOException, InterruptedException {
return getCurrentNode().createLauncher(listener);
Launcher l = getCurrentNode().createLauncher(listener);
if (project instanceof BuildableItemWithBuildWrappers) {
BuildableItemWithBuildWrappers biwbw = (BuildableItemWithBuildWrappers) project;
for(BuildWrapper bw : biwbw.getBuildWrappersList())
l = bw.decorateLauncher(AbstractBuild.this,l,listener);
}
buildEnvironments = new ArrayList<Environment>();
for (NodeProperty nodeProperty: Hudson.getInstance().getGlobalNodeProperties()) {
Environment environment = nodeProperty.setUp(AbstractBuild.this, l, listener);
if (environment != null) {
buildEnvironments.add(environment);
}
}
for (NodeProperty nodeProperty: Computer.currentComputer().getNode().getNodeProperties()) {
Environment environment = nodeProperty.setUp(AbstractBuild.this, l, listener);
if (environment != null) {
buildEnvironments.add(environment);
}
}
return l;
}
private void createSymLink(BuildListener listener, String name) throws InterruptedException {
......
......@@ -148,35 +148,6 @@ public abstract class Build <P extends Project<P,B>,B extends Build<P,B>>
return null;
}
/**
* Decorates the {@link Launcher}
*/
@Override
protected Launcher createLauncher(BuildListener listener) throws IOException, InterruptedException {
Launcher l = super.createLauncher(listener);
for(BuildWrapper bw : project.getBuildWrappers().values())
l = bw.decorateLauncher(Build.this,l,listener);
buildEnvironments = new ArrayList<Environment>();
for (NodeProperty nodeProperty: Hudson.getInstance().getGlobalNodeProperties()) {
Environment environment = nodeProperty.setUp(Build.this, l, listener);
if (environment != null) {
buildEnvironments.add(environment);
}
}
for (NodeProperty nodeProperty: Computer.currentComputer().getNode().getNodeProperties()) {
Environment environment = nodeProperty.setUp(Build.this, l, listener);
if (environment != null) {
buildEnvironments.add(environment);
}
}
return l;
}
public void post2(BuildListener listener) throws IOException, InterruptedException {
performAllBuildStep(listener, project.getPublishers(),true);
performAllBuildStep(listener, project.getProperties(),true);
......
package hudson.model;
import hudson.tasks.BuildWrapper;
import hudson.util.DescribableList;
/**
* {@link AbstractProject} that has associated {@link BuildWrapper}s.
*
* @author Kohsuke Kawaguchi
* @since 1.335
*/
public interface BuildableItemWithBuildWrappers extends BuildableItem {
/**
* {@link BuildableItemWithBuildWrappers} needs to be an instance of
* {@link AbstractProject}.
*
* <p>
* This method must be always implemented as {@code (AbstractProject)this}, but
* defining this method emphasizes the fact that this cast must be doable.
*/
AbstractProject<?,?> asProject();
/**
* {@link BuildWrapper}s associated with this {@link AbstractProject}.
*
* @return
* can be empty but never null. This list is live, and changes to it will be reflected
* to the project configuration.
*/
DescribableList<BuildWrapper,Descriptor<BuildWrapper>> getBuildWrappersList();
}
......@@ -54,7 +54,7 @@ import java.util.Set;
* @author Kohsuke Kawaguchi
*/
public abstract class Project<P extends Project<P,B>,B extends Build<P,B>>
extends AbstractProject<P,B> implements SCMedItem, Saveable, ProjectWithMaven {
extends AbstractProject<P,B> implements SCMedItem, Saveable, ProjectWithMaven, BuildableItemWithBuildWrappers {
/**
* List of active {@link Builder}s configured for this project.
......@@ -117,6 +117,10 @@ public abstract class Project<P extends Project<P,B>,B extends Build<P,B>>
return buildWrappers.toMap();
}
public DescribableList<BuildWrapper, Descriptor<BuildWrapper>> getBuildWrappersList() {
return buildWrappers;
}
@Override
protected Set<ResourceActivity> getResourceActivities() {
final Set<ResourceActivity> activities = new HashSet<ResourceActivity>();
......
......@@ -494,8 +494,7 @@ public class MavenBuild extends AbstractMavenBuild<MavenModule,MavenBuild> {
if(debug)
listener.getLogger().println("Reporters="+reporters);
buildEnvironments = new ArrayList<Environment>();
for (BuildWrapper w : mms.getBuildWrappers()) {
for (BuildWrapper w : mms.getBuildWrappersList()) {
Environment e = w.setUp(MavenBuild.this, launcher, listener);
if (e == null) {
return Result.FAILURE;
......
......@@ -61,7 +61,7 @@ import org.kohsuke.stapler.export.Exported;
*
* @author Kohsuke Kawaguchi
*/
public final class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenModuleSetBuild> implements TopLevelItem, ItemGroup<MavenModule>, SCMedItem, Saveable {
public final class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenModuleSetBuild> implements TopLevelItem, ItemGroup<MavenModule>, SCMedItem, Saveable, BuildableItemWithBuildWrappers {
/**
* All {@link MavenModule}s, keyed by their {@link MavenModule#getModuleName()} module name}s.
*/
......@@ -338,8 +338,15 @@ public final class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,Ma
return publishers;
}
public DescribableList<BuildWrapper, Descriptor<BuildWrapper>> getBuildWrappersList() {
return buildWrappers;
}
/**
* List of active {@link BuildWrapper}s. Can be empty but never null.
*
* @deprecated as of 1.335
* Use {@link #getBuildWrappersList()} to be consistent with other subtypes of {@link AbstractProject}.
*/
public DescribableList<BuildWrapper, Descriptor<BuildWrapper>> getBuildWrappers() {
return buildWrappers;
......
......@@ -398,13 +398,12 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
// do builds here
try {
List<BuildWrapper> wrappers = new ArrayList<BuildWrapper>();
for (BuildWrapper w : project.getBuildWrappers())
for (BuildWrapper w : project.getBuildWrappersList())
wrappers.add(w);
ParametersAction parameters = getAction(ParametersAction.class);
if (parameters != null)
parameters.createBuildWrappers(MavenModuleSetBuild.this,wrappers);
buildEnvironments = new ArrayList<Environment>();
for( BuildWrapper w : wrappers) {
Environment e = w.setUp(MavenModuleSetBuild.this, launcher, listener);
if(e==null)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册