Skip to content

Commit

Permalink
[FIXED JENKINS-11893] adding global env variables to config substitut…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
rpetti committed Nov 30, 2011
1 parent 9ebaf4e commit 09f3a7a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/main/java/hudson/plugins/perforce/PerforceSCM.java
Expand Up @@ -37,6 +37,8 @@
import hudson.scm.SCM;
import hudson.scm.SCMDescriptor;
import hudson.scm.SCMRevisionState;
import hudson.slaves.EnvironmentVariablesNodeProperty;
import hudson.slaves.NodeProperty;
import hudson.util.FormValidation;
import hudson.util.LogTaskListener;

Expand Down Expand Up @@ -450,6 +452,11 @@ private Hashtable<String, String> getDefaultSubstitutions(AbstractProject projec
}
}
}
for (NodeProperty nodeProperty: Hudson.getInstance().getGlobalNodeProperties()) {
if (nodeProperty instanceof EnvironmentVariablesNodeProperty) {
subst.putAll( ((EnvironmentVariablesNodeProperty)nodeProperty).getEnvVars() );
}
}
return subst;
}

Expand Down Expand Up @@ -1761,6 +1768,19 @@ static String substituteParameters(String string, AbstractBuild build) {
subst.put("BUILD_TAG", hudsonName + "-" + build.getProject().getName() + "-" + String.valueOf(build.getNumber()));
subst.put("BUILD_ID", build.getId());
subst.put("BUILD_NUMBER", String.valueOf(build.getNumber()));

//get global properties
for (NodeProperty nodeProperty: Hudson.getInstance().getGlobalNodeProperties()) {
if (nodeProperty instanceof EnvironmentVariablesNodeProperty) {
subst.putAll( ((EnvironmentVariablesNodeProperty)nodeProperty).getEnvVars() );
}
}
//get node-specific global properties
for(NodeProperty nodeProperty : build.getBuiltOn().getNodeProperties()){
if(nodeProperty instanceof EnvironmentVariablesNodeProperty) {
subst.putAll( ((EnvironmentVariablesNodeProperty)nodeProperty).getEnvVars() );
}
}
String result = substituteParameters(string, build.getBuildVariables());
result = substituteParameters(result, subst);
return result;
Expand Down

0 comments on commit 09f3a7a

Please sign in to comment.