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
-
Method Summary
Modifier and TypeMethodDescriptionstatic EnvironmentExpander
Provides an expander for a constant map of string keys and string values.abstract void
May add environment variables to a context.static EnvVars
getEffectiveEnvironment
(EnvVars customEnvironment, EnvVars contextualEnvironment, EnvironmentExpander expander) Deprecated.static EnvVars
getEffectiveEnvironment
(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 EnvironmentExpander
merge
(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:
IOException
InterruptedException
-
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+XYZ
overrides.- 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
subsequent
in caseoriginal
is null)
-
getEffectiveEnvironment
@Deprecated @NonNull public static EnvVars getEffectiveEnvironment(@NonNull EnvVars customEnvironment, @CheckForNull EnvVars contextualEnvironment, @CheckForNull EnvironmentExpander expander) throws IOException, InterruptedException Deprecated.- Throws:
IOException
InterruptedException
-
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 fromDefaultStepContext
andEnvActionImpl
. The precedence order is:StepEnvironmentContributor
s (if any)expander
(if any)customEnvironment
contextualEnvironment
(if any)
- Parameters:
customEnvironment
-Run.getEnvironment(TaskListener)
, orEnvironmentAction#getEnvironment
contextualEnvironment
- 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:
IOException
InterruptedException
-
getEffectiveEnvironment(EnvVars, EnvVars, EnvironmentExpander, StepContext, TaskListener)
to allowStepEnvironmentContributor
s to run.