|
|||||||||
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<java.lang.String,java.lang.String>
com.pmease.quickbuild.execution.killtree.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 |
---|
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
Constructor Summary | |
---|---|
EnvVars()
|
|
EnvVars(EnvVars m)
|
|
EnvVars(java.util.Map<java.lang.String,java.lang.String> m)
|
|
EnvVars(java.lang.String... keyValuePairs)
Builds an environment variables from an array of the form "key","value","key","value"... |
Method Summary | |
---|---|
void |
addLine(java.lang.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. |
java.lang.String |
expand(java.lang.String s)
Expands the variables in the given string by using environment variables represented in 'this'. |
java.lang.String |
get(java.lang.String key,
java.lang.String defaultValue)
Convenience message |
void |
override(java.lang.String key,
java.lang.String value)
Overrides the current entry by the given entry. |
EnvVars |
overrideAll(java.util.Map<java.lang.String,java.lang.String> all)
Overrides all values in the map by the given map. |
EnvVars |
overrideExpandingAll(java.util.Map<java.lang.String,java.lang.String> all)
Overrides all values in the map by the given map. |
java.lang.String |
put(java.lang.String key,
java.lang.String value)
|
void |
putIfNotNull(java.lang.String key,
java.lang.String value)
Add a key/value but only if the value is not-null. |
static void |
resolve(java.util.Map<java.lang.String,java.lang.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 |
Constructor Detail |
---|
public EnvVars()
public EnvVars(java.util.Map<java.lang.String,java.lang.String> m)
public EnvVars(EnvVars m)
public EnvVars(java.lang.String... keyValuePairs)
Method Detail |
---|
public void override(java.lang.String key, java.lang.String value)
Handles PATH+XYZ notation.
public EnvVars overrideAll(java.util.Map<java.lang.String,java.lang.String> all)
override(String, String)
.
public EnvVars overrideExpandingAll(java.util.Map<java.lang.String,java.lang.String> all)
override(String, String)
.
public static void resolve(java.util.Map<java.lang.String,java.lang.String> env)
public java.lang.String get(java.lang.String key, java.lang.String defaultValue)
public java.lang.String put(java.lang.String key, java.lang.String value)
put
in interface java.util.Map<java.lang.String,java.lang.String>
put
in class java.util.TreeMap<java.lang.String,java.lang.String>
public void putIfNotNull(java.lang.String key, java.lang.String value)
public void addLine(java.lang.String line)
public java.lang.String expand(java.lang.String s)
public static EnvVars createCookie()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |