mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-17 14:02:22 +00:00
added an ugly mechanism to propagate Combination values to builders.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3544 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
6df6aab741
commit
d2bb200c4e
5 files changed
+42
-3
No files matched your search
@@ -4,6 +4,9 @@ import hudson.model.Build;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* Execution of {@link MatrixConfiguration}.
|
||||
@@ -19,6 +22,19 @@ public class MatrixRun extends Build<MatrixConfiguration,MatrixRun> {
|
||||
super(project, buildDir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,String> getBuildVariables() {
|
||||
AxisList axes = getParent().getParent().getAxes();
|
||||
|
||||
// pick up user axes
|
||||
Map<String,String> r = new HashMap<String,String>();
|
||||
for (Entry<String,String> e : getParent().getCombination().entrySet()) {
|
||||
if(!axes.find(e.getKey()).isSystem())
|
||||
r.put(e.getKey(),e.getValue());
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MatrixConfiguration getParent() {// don't know why, but javac wants this
|
||||
return super.getParent();
|
||||
|
||||
@@ -6,6 +6,7 @@ import hudson.tasks.BuildWrapper.Environment;
|
||||
import hudson.tasks.Builder;
|
||||
import hudson.tasks.Publisher;
|
||||
import hudson.triggers.SCMTrigger;
|
||||
import hudson.matrix.MatrixConfiguration;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
|
||||
import java.io.File;
|
||||
@@ -13,6 +14,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* A build of a {@link Project}.
|
||||
@@ -85,6 +87,21 @@ public abstract class Build <P extends Project<P,B>,B extends Build<P,B>>
|
||||
return env;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides additional variables and their values to {@link Builder}s.
|
||||
*
|
||||
* <p>
|
||||
* This mechanism is used by {@link MatrixConfiguration} to pass
|
||||
* the configuration values to the current build. It is up to
|
||||
* {@link Builder}s to decide whether it wants to recognize the values
|
||||
* or how to use them.
|
||||
*
|
||||
* ugly ugly hack.
|
||||
*/
|
||||
public Map<String,String> getBuildVariables() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
public Api getApi(final StaplerRequest req) {
|
||||
return new Api(this);
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@ public class Ant extends Builder {
|
||||
}
|
||||
args.add(exec.getPath());
|
||||
}
|
||||
args.addKeyValuePairs("-D",build.getBuildVariables());
|
||||
args.addTokenized(normalizedTarget);
|
||||
|
||||
Map<String,String> env = build.getEnvVars();
|
||||
|
||||
@@ -8,6 +8,7 @@ import hudson.FilePath;
|
||||
import hudson.Util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Common part between {@link Shell} and {@link BatchFile}.
|
||||
@@ -45,7 +46,9 @@ public abstract class CommandInterpreter extends Builder {
|
||||
|
||||
int r;
|
||||
try {
|
||||
r = launcher.launch(cmd,build.getEnvVars(),listener.getLogger(),ws).join();
|
||||
Map<String,String> envVars = build.getEnvVars();
|
||||
envVars.putAll(build.getBuildVariables());
|
||||
r = launcher.launch(cmd,envVars,listener.getLogger(),ws).join();
|
||||
} catch (IOException e) {
|
||||
Util.displayIOException(e,listener);
|
||||
e.printStackTrace( listener.fatalError("command execution failed") );
|
||||
|
||||
@@ -126,7 +126,7 @@ public class Maven extends Builder {
|
||||
MavenInstallation ai = getMaven();
|
||||
if(ai==null) {
|
||||
String execName = proj.getWorkspace().act(new DecideDefaultMavenCommand(normalizedTarget));
|
||||
args.add(execName).addTokenized(normalizedTarget);
|
||||
args.add(execName);
|
||||
} else {
|
||||
File exec = ai.getExecutable();
|
||||
if(exec==null) {
|
||||
@@ -137,8 +137,10 @@ public class Maven extends Builder {
|
||||
listener.fatalError(exec+" doesn't exist");
|
||||
return false;
|
||||
}
|
||||
args.add(exec.getPath()).addTokenized(normalizedTarget);
|
||||
args.add(exec.getPath());
|
||||
}
|
||||
args.addKeyValuePairs("-D",build.getBuildVariables());
|
||||
args.addTokenized(normalizedTarget);
|
||||
|
||||
Map<String,String> env = build.getEnvVars();
|
||||
if(ai!=null) {
|
||||
|
||||
Reference in new issue
Block a user