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 class
EnvironmentInjector.CustomEnvironmentContributor
Deprecated.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
inject(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
EnvironmentContributingAction
is more preferred for the environment variable injection. However, is not compatible with workflow at the time of implementation.We register the
EnvironmentInjector.CustomEnvironmentContributor
which scans for privateEnvironmentInjectionAction
bound to the Run instance, and updates the environment variables accordingly. This will be called byRun.getEnvironment(TaskListener)
.In pipeline, the
EnvVars
should be fetched fromStepContext#get(EnvVars.class)
, and it will not contain the changes to the environment variables bound to theRun
object. In that case we should modify theEnvVars
returned 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 ofEnvVars
which needs to be updated at the same timename
- the variable namevalue
- the variable value- See Also:
EnvironmentInjector.CustomEnvironmentContributor
, JENKINS-29537
-
-