Skip to content
Permalink
Browse files

[FIXED JENKINS-12837] use full build environment for substitutions, n…

…ot just job parameters
  • Loading branch information...
rpetti committed Feb 21, 2012
1 parent 28353aa commit 5befc6822dbb7af0fb0f18a535efa0c826b89838
Showing with 20 additions and 0 deletions.
  1. +20 −0 src/main/java/hudson/plugins/perforce/PerforceSCM.java
@@ -1853,6 +1853,26 @@ public String getAppName() {

static String substituteParameters(String string, AbstractBuild build) {
Hashtable<String,String> subst = new Hashtable<String,String>();

boolean useEnvironment = true;
//get full environment for build from jenkins
for(StackTraceElement ste : (new Throwable()).getStackTrace()){
if(ste.getMethodName().equals("buildEnvVars") &&
ste.getClassName().equals(PerforceSCM.class.getName())){
useEnvironment = false;
}
}
if(useEnvironment){
try {
EnvVars vars = build.getEnvironment(TaskListener.NULL);
subst.putAll(vars);
} catch (IOException ex) {
Logger.getLogger(PerforceSCM.class.getName()).log(Level.SEVERE, null, ex);
} catch (InterruptedException ex) {
Logger.getLogger(PerforceSCM.class.getName()).log(Level.SEVERE, null, ex);
}
}

subst.put("JOB_NAME", getSafeJobName(build));
String hudsonName = Hudson.getInstance().getDisplayName().toLowerCase();
subst.put("BUILD_TAG", hudsonName + "-" + build.getProject().getName() + "-" + String.valueOf(build.getNumber()));

0 comments on commit 5befc68

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