package hudson; import hudson.remoting.Callable; import hudson.remoting.VirtualChannel; import hudson.util.CaseInsensitiveComparator; import java.io.File; import java.io.IOException; import java.util.Collections; import java.util.Map; import java.util.TreeMap; /** * Environment variables. * *
* In Hudson, often we need to build up "environment variable overrides"
* on master, then to execute the process on slaves. This causes a problem
* when working with variables like PATH. So to make this work,
* we introduce a special convention PATH+FOO — all entries
* that starts with PATH+ are merged and prepended to the inherited
* PATH variable, on the process where a new process is executed.
*
* @author Kohsuke Kawaguchi
*/
public class EnvVars extends TreeMap
* Handles PATH+XYZ notation.
*/
public void override(String key, String value) {
if(value==null || value.length()==0) {
remove(key);
return;
}
int idx = key.indexOf('+');
if(idx>0) {
String realKey = key.substring(0,idx);
String v = get(realKey);
if(v==null) v=value;
else v=value+File.pathSeparatorChar+v;
put(realKey,v);
return;
}
put(key,value);
}
public void overrideAll(Map