/** * Computes an effective environment in a given context. * Used from {@code DefaultStepContext} and {@code EnvActionImpl}. * The precedence order is: * <ol> * <li>{@code expander} (if any) * <li>{@code customEnvironment} * <li>{@code contextualEnvironment} (if any) * </ol> * @param customEnvironment {@link Run#getEnvironment(TaskListener)}, or {@code EnvironmentAction#getEnvironment} * @param contextualEnvironment a possible override as per {@link BodyInvoker#withContext} (such as from {@link Computer#getEnvironment} called from {@code PlaceholderExecutable}) * @param expander a possible expander * @return the effective environment */ public static @Nonnull EnvVars getEffectiveEnvironment(@Nonnull EnvVars customEnvironment, @CheckForNull EnvVars contextualEnvironment, @CheckForNull EnvironmentExpander expander) throws IOException, InterruptedException { EnvVars env; if (contextualEnvironment != null) { env = new EnvVars(contextualEnvironment); env.putAll(customEnvironment); } else { env = new EnvVars(customEnvironment); } if (expander != null) { expander.expand(env); } return env; }
/** * Computes an effective environment in a given context. * Used from {@code DefaultStepContext} and {@code EnvActionImpl}. * The precedence order is: * <ol> * <li>{@code expander} (if any) * <li>{@code customEnvironment} * <li>{@code contextualEnvironment} (if any) * </ol> * @param customEnvironment {@link Run#getEnvironment(TaskListener)}, or {@code EnvironmentAction#getEnvironment} * @param contextualEnvironment a possible override as per {@link BodyInvoker#withContext} (such as from {@link Computer#getEnvironment} called from {@code PlaceholderExecutable}) * @param expander a possible expander * @return the effective environment */ public static @Nonnull EnvVars getEffectiveEnvironment(@Nonnull EnvVars customEnvironment, @CheckForNull EnvVars contextualEnvironment, @CheckForNull EnvironmentExpander expander) throws IOException, InterruptedException { EnvVars env; if (contextualEnvironment != null) { env = new EnvVars(contextualEnvironment); env.putAll(customEnvironment); } else { env = new EnvVars(customEnvironment); } if (expander != null) { expander.expand(env); } return env; }
environmentExpander.expand(envVars);