|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.TreeMap<String,String>
hudson.EnvVars
public class EnvVars
Environment variables.
While all the platforms I tested (Linux 2.6, Solaris, and Windows XP) have the case sensitive environment variable table, Windows batch script handles environment variable in the case preserving but case insensitive way (that is, cmd.exe can get both FOO and foo as environment variables when it's launched, and the "set" command will display it accordingly, but "echo %foo%" results in echoing the value of "FOO", not "foo" — this is presumably caused by the behavior of the underlying Win32 API GetEnvironmentVariable acting in case insensitive way.) Windows users are also used to write environment variable case-insensitively (like %Path% vs %PATH%), and you can see many documents on the web that claims Windows environment variables are case insensitive.
So for a consistent cross platform behavior, it creates the least confusion to make the table case insensitive but case preserving.
In Jenkins, 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.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.util.AbstractMap |
---|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V> |
Field Summary | |
---|---|
static Map<String,String> |
masterEnvVars
Environmental variables that we've inherited. |
Constructor Summary | |
---|---|
EnvVars()
|
|
EnvVars(EnvVars m)
|
|
EnvVars(Map<String,String> m)
|
|
EnvVars(String... keyValuePairs)
Builds an environment variables from an array of the form "key","value","key","value"... |
Method Summary | |
---|---|
void |
addLine(String line)
Takes a string that looks like "a=b" and adds that to this map. |
static EnvVars |
createCookie()
Creates a magic cookie that can be used as the model environment variable when we later kill the processes. |
String |
expand(String s)
Expands the variables in the given string by using environment variables represented in 'this'. |
String |
get(String key,
String defaultValue)
Convenience message |
static EnvVars |
getRemote(hudson.remoting.VirtualChannel channel)
Obtains the environment variables of a remote peer. |
void |
override(String key,
String value)
Overrides the current entry by the given entry. |
EnvVars |
overrideAll(Map<String,String> all)
Overrides all values in the map by the given map. |
String |
put(String key,
String value)
|
static void |
resolve(Map<String,String> env)
Resolves environment variables against each other. |
Methods inherited from class java.util.TreeMap |
---|
ceilingEntry, ceilingKey, clear, clone, comparator, containsKey, containsValue, descendingKeySet, descendingMap, entrySet, firstEntry, firstKey, floorEntry, floorKey, get, headMap, headMap, higherEntry, higherKey, keySet, lastEntry, lastKey, lowerEntry, lowerKey, navigableKeySet, pollFirstEntry, pollLastEntry, putAll, remove, size, subMap, subMap, tailMap, tailMap, values |
Methods inherited from class java.util.AbstractMap |
---|
equals, hashCode, isEmpty, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
equals, hashCode, isEmpty |
Field Detail |
---|
public static final Map<String,String> masterEnvVars
Despite what the name might imply, this is the environment variable of the current JVM process. And therefore, it is Jenkins master's environment variables only when you access this from the master.
If you access this field from slaves, then this is the environment variable of the slave agent.
Constructor Detail |
---|
public EnvVars()
public EnvVars(Map<String,String> m)
public EnvVars(EnvVars m)
public EnvVars(String... keyValuePairs)
Method Detail |
---|
public void override(String key, String value)
Handles PATH+XYZ notation.
public EnvVars overrideAll(Map<String,String> all)
override(String, String)
.
public static void resolve(Map<String,String> env)
public String get(String key, String defaultValue)
public String put(String key, String value)
put
in interface Map<String,String>
put
in class TreeMap<String,String>
public void addLine(String line)
public String expand(String s)
public static EnvVars createCookie()
public static EnvVars getRemote(hudson.remoting.VirtualChannel channel) throws IOException, InterruptedException
channel
- Can be null, in which case the map indicating "N/A" will be returned.
IOException
InterruptedException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |