Skip to content

Commit

Permalink
Merge pull request #393 from mrjgreen/JENKINS-50429-2
Browse files Browse the repository at this point in the history
JENKINS-50429 combine env vars into a single set before writing once
  • Loading branch information
carlossg authored Dec 28, 2018
2 parents 4243781 + 53890c2 commit 3a7cdb8
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,29 +347,33 @@ public void onClose(int i, String s) {
String.format("cd \"%s\"%s", pwd, NEWLINE).getBytes(StandardCharsets.UTF_8));

}

EnvVars envVars = new EnvVars();

//get global vars here, run the export first as they'll get overwritten.
if (globalVars != null) {
this.setupEnvironmentVariable(globalVars, watch);
envVars.overrideAll(globalVars);
}

if(rcEnvVars != null) {
this.setupEnvironmentVariable(rcEnvVars, watch);
envVars.overrideAll(rcEnvVars);
}

EnvVars envVars = new EnvVars();
if (environmentExpander != null) {
environmentExpander.expand(envVars);
}

//setup specific command envs passed into cmd
if (cmdEnvs != null) {
LOGGER.log(Level.FINEST, "Launching with env vars: {0}", Arrays.toString(cmdEnvs));
for (String cmdEnv : cmdEnvs) {
envVars.addLine(cmdEnv);
}
}

LOGGER.log(Level.FINEST, "Launching with env vars: {0}", envVars.toString());

this.setupEnvironmentVariable(envVars, watch);

doExec(watch, printStream, masks, commands);
if (closables == null) {
closables = new ArrayList<>();
Expand Down

0 comments on commit 3a7cdb8

Please sign in to comment.