Skip to content
Permalink
Browse files

Fix JENKINS-16219

  • Loading branch information...
gboissinot committed Dec 28, 2012
1 parent 9734300 commit 368ba74a6ed995e89013f860827a47920e9668c7
@@ -3,20 +3,36 @@
import hudson.Extension;
import hudson.model.AbstractBuild;
import hudson.model.BuildVariableContributor;
import hudson.model.ParameterValue;
import hudson.model.ParametersAction;

import java.util.Map;

/**
* @author Gregory Boissinot
*/

/**
* Overriding job parameters with environment variables populated by EnvInject plugin
*/
@Extension
public class EnvInjectBuildVariableContributor extends BuildVariableContributor {

@Override
public void buildVariablesFor(AbstractBuild build, Map<String, String> variables) {
EnvInjectPluginAction envInjectAction = build.getAction(EnvInjectPluginAction.class);
if (envInjectAction != null) {
variables.putAll(envInjectAction.getEnvMap());
ParametersAction parameters = build.getAction(ParametersAction.class);
//Only for a parameterized job
if (parameters != null) {
EnvInjectPluginAction envInjectAction = build.getAction(EnvInjectPluginAction.class);
if (envInjectAction != null) {
for (ParameterValue p : parameters) {
String key = p.getName();
Map<String, String> injectedEnvVars = envInjectAction.getEnvMap();
if (injectedEnvVars.containsKey(key)) {
variables.put(key, injectedEnvVars.get(key));
}
}
}
}
}
}

0 comments on commit 368ba74

Please sign in to comment.
You can’t perform that action at this time.