Class EnvironmentExpander
- java.lang.Object
-
- org.jenkinsci.plugins.workflow.steps.EnvironmentExpander
-
- All Implemented Interfaces:
Serializable
public abstract class EnvironmentExpander extends Object implements Serializable
Interface destined forStepContext.get(java.lang.Class<T>)
instead of rawEnvVars
. Pass intoBodyInvoker.withContext(java.lang.Object)
.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description EnvironmentExpander()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static EnvironmentExpander
constant(Map<String,String> env)
Provides an expander for a constant map of string keys and string values.abstract void
expand(EnvVars env)
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.Set<String>
getSensitiveVariables()
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.
-
-
-
Method Detail
-
expand
public abstract void expand(@NonNull EnvVars env) throws IOException, InterruptedException
May add environment variables to a context.- Parameters:
env
- an original set of environment variables- Throws:
IOException
InterruptedException
-
getSensitiveVariables
@NonNull public Set<String> 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
public static EnvironmentExpander constant(@NonNull Map<String,String> env)
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
-
-