Package com.atlassian.bamboo.process
Class EnvironmentVariableAccessorImpl
java.lang.Object
com.atlassian.bamboo.process.EnvironmentVariableAccessorImpl
- All Implemented Interfaces:
EnvironmentVariableAccessor
-
Field Summary
Fields inherited from interface com.atlassian.bamboo.process.EnvironmentVariableAccessor
MAX_SAFE_ENVIRONMENT_LENGTH, MAX_SAFE_INDIVIDUAL_VARIABLE_LENGTH
-
Constructor Summary
ConstructorDescriptionEnvironmentVariableAccessorImpl
(CapabilityContext capabilityContext, CustomVariableContext customVariableContext) -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull String
forceLegalIdentifier
(@NotNull String key) getEnvironment
(@NotNull CommonTaskContext taskContext) UseTaskContext
as a source of environment settings.getPaths
(@NotNull CommonTaskContext taskContext) UseTaskContext
as a source of additional PATH settings.@NotNull String
joinEnvironmentVariables
(@NotNull Iterable<Map.Entry<String, String>> environmentVariables) Concatenate environment variables into string.@NotNull String
joinEnvironmentVariables
(@NotNull Map<String, String> environmentVariables) Concatenate environment variables into string.splitEnvironmentAssignments
(@NotNull String environmentAssignments) Splits "Environment settings" string into array of separate strings.splitEnvironmentAssignments
(@NotNull String environmentAssignments, boolean processBackslashes) Splits "Environment settings" string into array of separate strings.void
validateEnvironmentVariables
(@NotNull Iterable<Map.Entry<String, String>> environmentVariables) Perform basic validation of environment settings before passing it to process-utilsvoid
validateEnvironmentVariables
(@NotNull Map<String, String> environmentVariables) Perform basic validation of environment settings before passing it to process-utils
-
Constructor Details
-
EnvironmentVariableAccessorImpl
public EnvironmentVariableAccessorImpl(CapabilityContext capabilityContext, CustomVariableContext customVariableContext)
-
-
Method Details
-
getEnvironment
- Specified by:
getEnvironment
in interfaceEnvironmentVariableAccessor
-
getEnvironment
@NotNull public @NotNull Map<String,String> getEnvironment(@NotNull @NotNull CommonTaskContext taskContext) Description copied from interface:EnvironmentVariableAccessor
UseTaskContext
as a source of environment settings. The following variables will be returned - variables for variable definitions from taskContext - JAVA_HOME (if defined in task configuration and appropriate capability exists)- Specified by:
getEnvironment
in interfaceEnvironmentVariableAccessor
- Parameters:
taskContext
-TaskContext
object- Returns:
- Key-value map
-
getPaths
Description copied from interface:EnvironmentVariableAccessor
UseTaskContext
as a source of additional PATH settings. The following values might be returned - $JAVA_HOME/bin (if defined in task configuration and appropriate capability exists)- Specified by:
getPaths
in interfaceEnvironmentVariableAccessor
- Parameters:
taskContext
-TaskContext
object- Returns:
- List of paths (which will be probably added to PATH by caller
-
joinEnvironmentVariables
@NotNull public @NotNull String joinEnvironmentVariables(@NotNull @NotNull Map<String, String> environmentVariables) Description copied from interface:EnvironmentVariableAccessor
Concatenate environment variables into string.- Specified by:
joinEnvironmentVariables
in interfaceEnvironmentVariableAccessor
- Parameters:
environmentVariables
- Map of key-value pairs to be concatenated- Returns:
- concatenated environment variables in form "KEY1=VALUE1 KEY2=VALUE2 ..."
-
joinEnvironmentVariables
@NotNull public @NotNull String joinEnvironmentVariables(@NotNull @NotNull Iterable<Map.Entry<String, String>> environmentVariables) Description copied from interface:EnvironmentVariableAccessor
Concatenate environment variables into string.- Specified by:
joinEnvironmentVariables
in interfaceEnvironmentVariableAccessor
- Parameters:
environmentVariables
- Map.Entry iterable of key-value pairs to be concatenated- Returns:
- concatenated environment variables in form "KEY1=VALUE1 KEY2=VALUE2 ..."
-
splitEnvironmentAssignments
@NotNull public @NotNull Map<String,String> splitEnvironmentAssignments(@NotNull @NotNull String environmentAssignments, boolean processBackslashes) Description copied from interface:EnvironmentVariableAccessor
Splits "Environment settings" string into array of separate strings. Quoting is taken into consideration. An environment setting is defined as a sequence of characters [noquote]+([quote][noquote]+[quote])? or [quote][noquote][quote]- Specified by:
splitEnvironmentAssignments
in interfaceEnvironmentVariableAccessor
- Parameters:
environmentAssignments
- the string containing KEY=VALUE assignments separated with white charactersprocessBackslashes
- whether to treat a backslash as an ordinary or quoting character- Returns:
- Map of separated environment settings.
-
splitEnvironmentAssignments
@NotNull public @NotNull Map<String,String> splitEnvironmentAssignments(@NotNull @NotNull String environmentAssignments) Description copied from interface:EnvironmentVariableAccessor
Splits "Environment settings" string into array of separate strings. Quoting using single and double quotes, but not backslashes is taken into consideration. An environment setting is defined as a sequence of characters. [noquote]+([quote][noquote]+[quote])? or [quote][noquote][quote]- Specified by:
splitEnvironmentAssignments
in interfaceEnvironmentVariableAccessor
- Parameters:
environmentAssignments
- string containing KEY=VALUE assignments separated with white characters- Returns:
- Map of separated environment settings.
-
validateEnvironmentVariables
Description copied from interface:EnvironmentVariableAccessor
Perform basic validation of environment settings before passing it to process-utils- Specified by:
validateEnvironmentVariables
in interfaceEnvironmentVariableAccessor
- Parameters:
environmentVariables
- Map.Entry iterable of key-value pairs to be concatenated
-
validateEnvironmentVariables
public void validateEnvironmentVariables(@NotNull @NotNull Iterable<Map.Entry<String, String>> environmentVariables) Description copied from interface:EnvironmentVariableAccessor
Perform basic validation of environment settings before passing it to process-utils- Specified by:
validateEnvironmentVariables
in interfaceEnvironmentVariableAccessor
- Parameters:
environmentVariables
- Map.Entry iterable of key-value pairs to be concatenated
-
forceLegalIdentifier
-