diff --git a/core/src/main/java/hudson/slaves/SlaveComputer.java b/core/src/main/java/hudson/slaves/SlaveComputer.java index c77d5aed30d9aba423b16736cea5a9ac8978a136..79d168d1a532839a77d63367e777799af5c475c3 100644 --- a/core/src/main/java/hudson/slaves/SlaveComputer.java +++ b/core/src/main/java/hudson/slaves/SlaveComputer.java @@ -26,6 +26,7 @@ package hudson.slaves; import hudson.AbortException; import hudson.FilePath; import hudson.Functions; +import hudson.Main; import hudson.RestrictedSince; import hudson.Util; import hudson.console.ConsoleLogFilter; @@ -87,6 +88,8 @@ import java.security.Security; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Map; +import java.util.TreeMap; import java.util.concurrent.Future; import java.util.logging.Handler; import java.util.logging.Level; @@ -902,6 +905,32 @@ public class SlaveComputer extends Computer { return channel.call(new DetectOS()) ? "Unix" : "Windows"; } + /** + * Expose real full env vars map from agent for UI presentation + */ + public Map getEnvVarsFull() throws IOException, InterruptedException { + if(getChannel() == null) { + Map env = new TreeMap<> (); + env.put("N/A","N/A"); + return env; + } else { + return getChannel().call(new ListFullEnvironment()); + } + } + + private static class ListFullEnvironment extends MasterToSlaveCallable,IOException> { + public Map call() throws IOException { + Map env = new TreeMap<>(System.getenv()); + if(Main.isUnitTest || Main.isDevelopmentMode) { + // if unit test is launched with maven debug switch, + // we need to prevent forked Maven processes from seeing it, or else + // they'll hang + env.remove("MAVEN_OPTS"); + } + return env; + } + } + private static final Logger logger = Logger.getLogger(SlaveComputer.class.getName()); private static final class SlaveVersion extends MasterToSlaveCallable { diff --git a/core/src/main/resources/jenkins/slaves/systemInfo/EnvVarsSlaveInfo/systemInfo.jelly b/core/src/main/resources/jenkins/slaves/systemInfo/EnvVarsSlaveInfo/systemInfo.jelly index 37af3c7c7531a9e32354e9f4924788fa8651924f..9525653a7b59cf8ab9a2492dd7fede38c1aaddf5 100644 --- a/core/src/main/resources/jenkins/slaves/systemInfo/EnvVarsSlaveInfo/systemInfo.jelly +++ b/core/src/main/resources/jenkins/slaves/systemInfo/EnvVarsSlaveInfo/systemInfo.jelly @@ -29,5 +29,5 @@ THE SOFTWARE. --> - + \ No newline at end of file