Skip to content

Commit

Permalink
Properly expand build environment variables, hopefully fix JENKINS-20478
Browse files Browse the repository at this point in the history


Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
  • Loading branch information
nekromant committed Nov 23, 2016
1 parent 9da2ce4 commit 99b2044
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/hudson/plugins/xshell/XShellBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,16 @@ public boolean perform(final AbstractBuild<?, ?> build, final Launcher launcher,
LOG.log(Level.FINE, "Regex to kill: " + regexToKill);
LOG.log(Level.FINE, "Time allocated before kill: " + timeAllocated);

final EnvVars env = build.getEnvironment(listener);


String cmdLine = convertSeparator(commandLine, (launcher.isUnix() ? UNIX_SEP : WINDOWS_SEP));
LOG.log(Level.FINE, "File separators sanitized: " + cmdLine);


cmdLine = env.expand(cmdLine);

LOG.log(Level.FINE, "Expanded build environment vars: " + cmdLine);

if (launcher.isUnix()) {
cmdLine = convertEnvVarsToUnix(cmdLine);
} else {
Expand All @@ -112,7 +119,6 @@ public boolean perform(final AbstractBuild<?, ?> build, final Launcher launcher,
LOG.log(Level.FINE, "Windows command: " + args.toStringWithQuote());
}

EnvVars env = build.getEnvironment(listener);
env.putAll(build.getBuildVariables());

LOG.log(Level.FINEST, "Environment variables: " + env.entrySet().toString());
Expand Down

0 comments on commit 99b2044

Please sign in to comment.