Skip to content
Permalink
Browse files

Fix JENKINS-16372

  • Loading branch information...
gboissinot committed Jan 29, 2013
1 parent 6cdf089 commit fffef515df17d3422c4c7b8bf0d719436b52bfab
@@ -172,7 +172,7 @@ private Environment setUpEnvironmentJobPropertyObject(AbstractBuild build, Launc
EnvInjectJobProperty envInjectJobProperty = variableGetter.getEnvInjectJobProperty(build);
assert envInjectJobProperty != null;
EnvInjectJobPropertyInfo info = envInjectJobProperty.getInfo();
assert envInjectJobProperty != null && envInjectJobProperty.isOn();
assert envInjectJobProperty.isOn();

//Init infra env vars
Map<String, String> previousEnvVars = variableGetter.getEnvVarsPreviousSteps(build, logger);
@@ -194,12 +194,6 @@ private Environment setUpEnvironmentJobPropertyObject(AbstractBuild build, Launc
infraEnvVarsNode.putAll(buildVariables);
}


//Add build parameters (or override)
logger.info("Adding build parameters as variables.");
Map<String, String> parametersVariables = variableGetter.overrideParametersVariablesWithSecret(build);
infraEnvVarsNode.putAll(parametersVariables);

final FilePath rootPath = getNodeRootPath();
if (rootPath != null) {

@@ -5,15 +5,13 @@
import hudson.matrix.MatrixRun;
import hudson.model.*;
import hudson.util.LogTaskListener;
import hudson.util.Secret;
import org.jenkinsci.lib.envinject.EnvInjectException;
import org.jenkinsci.lib.envinject.EnvInjectLogger;
import org.jenkinsci.plugins.envinject.EnvInjectJobProperty;
import org.jenkinsci.plugins.envinject.EnvInjectJobPropertyInfo;
import org.jenkinsci.plugins.envinject.EnvInjectPluginAction;

import java.io.IOException;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -109,31 +107,6 @@
return result;
}

public Map<String, String> overrideParametersVariablesWithSecret(AbstractBuild build) {
Map<String, String> result = new HashMap<String, String>();
ParametersAction params = build.getAction(ParametersAction.class);
if (params != null) {
for (ParameterValue p : params) {
try {
Field valueField = p.getClass().getDeclaredField("value");
valueField.setAccessible(true);
Object valueObject = valueField.get(p);
if (valueObject instanceof Secret) {
Secret secretValue = (Secret) valueObject;
result.put(p.getName(), secretValue.getEncryptedValue());
}
} catch (NoSuchFieldException e) {
//the field doesn't exist
//test the next param
continue;
} catch (IllegalAccessException e) {
continue;
}
}
}
return result;
}

@SuppressWarnings("unchecked")
public EnvInjectJobProperty getEnvInjectJobProperty(AbstractBuild build) {
if (build == null) {

0 comments on commit fffef51

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