Class EnvironmentInjector
- java.lang.Object
-
- com.microsoft.jenkins.azurecommons.EnvironmentInjector
-
@Deprecated public final class EnvironmentInjector extends Object
Deprecated.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEnvironmentInjector.CustomEnvironmentContributorDeprecated.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidinject(Run<?,?> run, EnvVars envVars, String name, Object value)Deprecated.Add an environment variable binding for the given Run.
-
-
-
Method Detail
-
inject
public static void inject(Run<?,?> run, EnvVars envVars, String name, Object value)
Deprecated.Add an environment variable binding for the given Run.The
EnvironmentContributingActionis more preferred for the environment variable injection. However, is not compatible with workflow at the time of implementation.We register the
EnvironmentInjector.CustomEnvironmentContributorwhich scans for privateEnvironmentInjectionActionbound to the Run instance, and updates the environment variables accordingly. This will be called byRun.getEnvironment(TaskListener).In pipeline, the
EnvVarsshould be fetched fromStepContext#get(EnvVars.class), and it will not contain the changes to the environment variables bound to theRunobject. In that case we should modify theEnvVarsreturned fromStepContext#get(EnvVars.class). Passing it as the second parameter of this method.Note that
Run.getEnvironment(TaskListener)returns a snapshot of the environment variables. If new variables are injected, we need to call it again to get the latest values. Or if you have a snapshot of theEnvVars, pass it as the second parameter so that it gets updated at the same time.- Parameters:
run- the run objectenvVars- the current set ofEnvVarswhich needs to be updated at the same timename- the variable namevalue- the variable value- See Also:
EnvironmentInjector.CustomEnvironmentContributor, JENKINS-29537
-
-