Permalink
Browse files

Fix JENKINS-12905

  • Loading branch information...
gboissinot committed Feb 27, 2012
1 parent e8d33d1 commit a3f9b080198f83d29c5aef8eeac10f232fe10c11
@@ -113,7 +113,7 @@ private Environment setUpEnvironmentNonMatrixRun(AbstractBuild build, Launcher l
//Get variables get by contribution
Map<String, String> contributionVariables = getEnvVarsByContribution(build, envInjectJobProperty, listener);
final Map<String, String> resultVariables = envInjectEnvVarsService.getMergedVariables(infraEnvVarsNode, propertiesVariables, contributionVariables);
final Map<String, String> resultVariables = envInjectEnvVarsService.getMergedVariables(infraEnvVarsNode, contributionVariables, propertiesVariables);
//Add an action
new EnvInjectActionSetter(rootPath).addEnvVarsToEnvInjectBuildAction(build, resultVariables);
@@ -101,27 +101,29 @@ public int executeScript(
}
public Map<String, String> getMergedVariables(Map<String, String> infraEnvVars, Map<String, String> propertiesEnvVars) {
Map<String, String> variables = new LinkedHashMap<String, String>(infraEnvVars);
variables.putAll(propertiesEnvVars);
return filterEnvVars(variables, variables);
return getMergedVariables(infraEnvVars, new HashMap<String, String>(), propertiesEnvVars);
}
public Map<String, String> getMergedVariables(Map<String, String> infraEnvVars, Map<String, String> propertiesEnvVars, Map<String, String> contribEnvVars) {
Map<String, String> variables = new LinkedHashMap<String, String>(infraEnvVars);
variables.putAll(propertiesEnvVars);
variables.putAll(contribEnvVars);
return filterEnvVars(variables, variables);
}
public Map<String, String> getMergedVariables(Map<String, String> infraEnvVars,
Map<String, String> contribEnvVars,
Map<String, String> propertiesEnvVars) {
private Map<String, String> filterEnvVars(Map<String, String> previousEnvVars, Map<String, String> variables) {
//1--Resolve properties against infraEnvVars
resolveVars(propertiesEnvVars, infraEnvVars);
//Resolve vars each other
resolveVars(variables, previousEnvVars);
//2--Resolve properties against contribEnvVars
resolveVars(propertiesEnvVars, contribEnvVars);
//Remove unset variables
//3-- Get All variables in order (infraEnvVars, contribEnvVars, properties)
Map<String, String> variables = new LinkedHashMap<String, String>(infraEnvVars);
variables.putAll(contribEnvVars);
variables.putAll(propertiesEnvVars);
//4-- Remove unset variables and return the resullt
return removeUnsetVars(variables);
}
private void resolveVars(Map<String, String> variables, Map<String, String> env) {
//Resolve variables against env

0 comments on commit a3f9b08

Please sign in to comment.