Skip to content
Permalink
Browse files

Fix JENKINS-12944

  • Loading branch information...
gboissinot committed Mar 2, 2012
1 parent f101df5 commit 1be2cee5f7bf55dfeb5c99525d181fa05d9faf02
Showing with 15 additions and 10 deletions.
  1. +15 −10 src/main/java/org/jenkinsci/plugins/envinject/service/EnvInjectVariableGetter.java
@@ -77,6 +77,10 @@
Map<String, String> triggerVariable = new BuildCauseRetriever().getTriggeredCause(build);
result.putAll(triggerVariable);

//Add workspace
FilePath ws = build.getWorkspace();
result.put("WORKSPACE", ws.getRemote());

return result;
}

@@ -105,8 +109,8 @@
return result;
}

public boolean isEnvInjectJobPropertyActive(AbstractBuild build) {

@SuppressWarnings("unchecked")
public EnvInjectJobProperty getEnvInjectJobProperty(AbstractBuild build) {
if (build == null) {
throw new IllegalArgumentException("A build object must be set.");
}
@@ -118,31 +122,32 @@ public boolean isEnvInjectJobPropertyActive(AbstractBuild build) {
job = build.getParent();
}

EnvInjectJobProperty envInjectJobProperty = getEnvInjectJobProperty(job);
EnvInjectJobProperty envInjectJobProperty = (EnvInjectJobProperty) job.getProperty(EnvInjectJobProperty.class);
if (envInjectJobProperty != null) {
EnvInjectJobPropertyInfo info = envInjectJobProperty.getInfo();
if (info != null && envInjectJobProperty.isOn()) {
return true;
return envInjectJobProperty;
}
}
return false;
}

@SuppressWarnings("unchecked")
public EnvInjectJobProperty getEnvInjectJobProperty(Job project) {
return (EnvInjectJobProperty) project.getProperty(EnvInjectJobProperty.class);
return null;
}

public Map<String, String> getEnvVarsPreviousSteps(AbstractBuild build, EnvInjectLogger logger) throws IOException, InterruptedException, EnvInjectException {
Map<String, String> result = new HashMap<String, String>();
EnvInjectDetector envInjectDetector = new EnvInjectDetector();
if (envInjectDetector.isEnvInjectActivated(build)) {
result.putAll(getCurrentInjectedEnvVars(build));

//Add workspace if not set
FilePath ws = build.getWorkspace();
if (ws != null) {
result.put("WORKSPACE", ws.getRemote());
}

//Add build variables with axis for a MatrixRun
if (build instanceof MatrixRun) {
result.putAll(build.getBuildVariables());
}
} else {
result.putAll(getJenkinsSystemVariablesCurrentNode(build));
result.putAll(getBuildVariables(build, logger));

0 comments on commit 1be2cee

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