Class EnvironmentExpander
java.lang.Object
org.jenkinsci.plugins.workflow.steps.EnvironmentExpander
- All Implemented Interfaces:
Serializable
Interface destined for
StepContext.get(java.lang.Class<T>) instead of raw EnvVars.
Pass into BodyInvoker.withContext(java.lang.Object).- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic EnvironmentExpanderProvides an expander for a constant map of string keys and string values.abstract voidMay add environment variables to a context.static EnvVarsgetEffectiveEnvironment(EnvVars customEnvironment, EnvVars contextualEnvironment, EnvironmentExpander expander) Deprecated.static EnvVarsgetEffectiveEnvironment(EnvVars customEnvironment, EnvVars contextualEnvironment, EnvironmentExpander expander, StepContext stepContext, TaskListener listener) Computes an effective environment in a given context.Get the names of environment variables known to contain sensitive values, such as secrets, in the current context.static EnvironmentExpandermerge(EnvironmentExpander original, EnvironmentExpander subsequent) Merge together two expanders.
-
Constructor Details
-
EnvironmentExpander
public EnvironmentExpander()
-
-
Method Details
-
expand
May add environment variables to a context.- Parameters:
env- an original set of environment variables- Throws:
IOExceptionInterruptedException
-
getSensitiveVariables
Get the names of environment variables known to contain sensitive values, such as secrets, in the current context. Should be overridden by subclasses that bind secret values to environment variables.- Returns:
- a set of environment variables known to contain sensitive values
-
constant
Provides an expander for a constant map of string keys and string values. SupportsEnvVars.override(String, String)behavior, such asPATH+XYZoverrides.- Parameters:
env- A non-null map of string keys and string values.- Returns:
- An expander which will provide the given map.
-
merge
public static EnvironmentExpander merge(@CheckForNull EnvironmentExpander original, @NonNull EnvironmentExpander subsequent) Merge together two expanders.- Parameters:
original- an original one, such as one already found in a contextsubsequent- what you are adding- Returns:
- an expander which runs them both in that sequence (or, as a convenience, just
subsequentin caseoriginalis null)
-
getEffectiveEnvironment
@Deprecated @NonNull public static EnvVars getEffectiveEnvironment(@NonNull EnvVars customEnvironment, @CheckForNull EnvVars contextualEnvironment, @CheckForNull EnvironmentExpander expander) throws IOException, InterruptedException Deprecated.- Throws:
IOExceptionInterruptedException
-
getEffectiveEnvironment
@NonNull public static EnvVars getEffectiveEnvironment(@NonNull EnvVars customEnvironment, @CheckForNull EnvVars contextualEnvironment, @CheckForNull EnvironmentExpander expander, @CheckForNull StepContext stepContext, @NonNull TaskListener listener) throws IOException, InterruptedException Computes an effective environment in a given context. Used fromDefaultStepContextandEnvActionImpl. The precedence order is:StepEnvironmentContributors (if any)expander(if any)customEnvironmentcontextualEnvironment(if any)
- Parameters:
customEnvironment-Run.getEnvironment(TaskListener), orEnvironmentAction#getEnvironmentcontextualEnvironment- a possible override as perBodyInvoker.withContext(java.lang.Object)(such as fromComputer.getEnvironment()called fromPlaceholderExecutable)expander- a possible expanderstepContext- the context of the step being executedlistener- Connected to the build console. Can be used to report errors.- Returns:
- the effective environment
- Throws:
IOExceptionInterruptedException
-
getEffectiveEnvironment(EnvVars, EnvVars, EnvironmentExpander, StepContext, TaskListener)to allowStepEnvironmentContributors to run.