Skip to content

Commit

Permalink
Merge pull request #65 from jenkinsci/JENKINS-40484
Browse files Browse the repository at this point in the history
[JENKINS-40484] Better troubleshooting messages
  • Loading branch information
Cyrille Le Clerc committed Jul 17, 2017
2 parents b9bee3c + 0193d7c commit 59702c5
Showing 1 changed file with 8 additions and 3 deletions.
Expand Up @@ -158,6 +158,7 @@ public boolean start() throws Exception {
LOGGER.log(Level.FINE, "Global settings Config: {0}", step.getGlobalMavenSettingsConfig());
LOGGER.log(Level.FINE, "Global settings FilePath: {0}", step.getGlobalMavenSettingsFilePath());
LOGGER.log(Level.FINE, "Options: {0}", step.getOptions());
LOGGER.log(Level.FINE, "env.PATH: {0}", env.get("PATH")); // JENKINS-40484
}

listener.getLogger().println("[withMaven] Options: " + step.getOptions());
Expand All @@ -174,6 +175,8 @@ public boolean start() throws Exception {
ConsoleLogFilter consFilter = BodyInvoker.mergeConsoleLogFilters(getContext().get(ConsoleLogFilter.class), new MavenConsoleFilter(getComputer().getDefaultCharset().name()));
EnvironmentExpander envEx = EnvironmentExpander.merge(getContext().get(EnvironmentExpander.class), new ExpanderImpl(envOverride));

LOGGER.log(Level.FINE, "envOverride: {0}", envOverride); // JENKINS-40484

body = getContext().newBodyInvoker().withContexts(envEx, consFilter).withCallback(new Callback(tempBinDir, step.getOptions())).start();

return false;
Expand Down Expand Up @@ -819,23 +822,25 @@ public OutputStream decorateLogger(AbstractBuild _ignore, final OutputStream log
}

/**
* Takes care of overriding the environment with our defined ovirrides
* Takes care of overriding the environment with our defined overrides
*/
private static final class ExpanderImpl extends EnvironmentExpander {
private static final long serialVersionUID = 1;
private final Map<String, String> overrides;

private ExpanderImpl(EnvVars overrides) {
LOGGER.log(Level.FINE, "Overrides: " + overrides.toString());
this.overrides = new HashMap<String, String>();
LOGGER.log(Level.FINER, "ExpanderImpl(overrides: {0})", new Object[]{overrides});
this.overrides = new HashMap<>();
for (Entry<String, String> entry : overrides.entrySet()) {
this.overrides.put(entry.getKey(), entry.getValue());
}
}

@Override
public void expand(EnvVars env) throws IOException, InterruptedException {
LOGGER.log(Level.FINER, "ExpanderImpl.expand - env before expand: {0}", new Object[]{env}); // JENKINS-40484
env.overrideAll(overrides);
LOGGER.log(Level.FINER, "ExpanderImpl.expand - env after expand: {0}", new Object[]{env}); // JENKINS-40484
}
}

Expand Down

0 comments on commit 59702c5

Please sign in to comment.