Skip to content

Commit

Permalink
[FIXED JENKINS-12837] use full build environment for substitutions, n…
Browse files Browse the repository at this point in the history
…ot just job parameters
  • Loading branch information
rpetti committed Feb 21, 2012
1 parent 28353aa commit 5befc68
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 @@ -1853,6 +1853,26 @@ public static List<String> parseProjectPath(String projectPath, String p4Client)

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()));
Expand Down

0 comments on commit 5befc68

Please sign in to comment.