Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
gboissinot committed Jan 29, 2013
1 parent 6cdf089 commit fffef51
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 34 deletions.
Expand Up @@ -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);
Expand All @@ -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) {

Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -109,31 +107,6 @@ public Map<String, String> getBuildVariables(AbstractBuild build, EnvInjectLogge
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) {
Expand Down

0 comments on commit fffef51

Please sign in to comment.