Class EnvironmentContributor
- java.lang.Object
-
- hudson.model.EnvironmentContributor
-
- All Implemented Interfaces:
ExtensionPoint
- Direct Known Subclasses:
CoreEnvironmentContributor
public abstract class EnvironmentContributor extends Object implements ExtensionPoint
Contributes environment variables to builds.This extension point can be used to externally add environment variables. Aside from adding environment variables of the fixed name, a typical strategy is to look for specific
JobPropertys and other similar configurations ofJobs to compute values.Views
buildEnv.groovy/.jelly
When Jenkins displays the help page listing all the environment variables available for a build, it does so by combining all thebuildEnvviews from this extension point. This view should use the<t:buildEnvVar>tag to render a variable.In this view,
itpoints toEnvironmentContributorandjobpoints toJobfor which the help is being rendered.Jenkins provides other extension points (such as
SCM) to contribute environment variables to builds, and for those plugins, Jenkins also looks for/buildEnv.groovyand aggregates them.- Since:
- 1.392
- Author:
- Kohsuke Kawaguchi
- See Also:
BuildVariableContributor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEnvironmentContributor.EnvVarsHtmlServes the combined list of environment variables available from this plugin.-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description EnvironmentContributor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ExtensionList<EnvironmentContributor>all()Returns all the registeredEnvironmentContributors.voidbuildEnvironmentFor(Job j, EnvVars envs, TaskListener listener)Contributes environment variables used for a job.voidbuildEnvironmentFor(Run r, EnvVars envs, TaskListener listener)Contributes environment variables used for a build.
-
-
-
Method Detail
-
buildEnvironmentFor
public void buildEnvironmentFor(@NonNull Run r, @NonNull EnvVars envs, @NonNull TaskListener listener) throws IOException, InterruptedExceptionContributes environment variables used for a build.This method can be called repeatedly for the same
Run, thus the computation of this method needs to be efficient. If you have a time-consuming computation, one strategy is to take the hit once and then add the result asInvisibleActiontoRun, then reuse those values later on.This method gets invoked concurrently for multiple
Runs that are being built at the same time, so it must be concurrent-safe.When building environment variables for a build, Jenkins will also invoke
buildEnvironmentFor(Job, EnvVars, TaskListener). This method only needs to add variables that are scoped to builds.- Parameters:
r- Build that's being performed.envs- Partially built environment variable map. Implementation of this method is expected to add additional variables here.listener- Connected to the build console. Can be used to report errors.- Throws:
IOExceptionInterruptedException
-
buildEnvironmentFor
public void buildEnvironmentFor(@NonNull Job j, @NonNull EnvVars envs, @NonNull TaskListener listener) throws IOException, InterruptedExceptionContributes environment variables used for a job.This method can be called repeatedly for the same
Job, thus the computation of this method needs to be efficient.This method gets invoked concurrently for multiple
Jobs, so it must be concurrent-safe.- Parameters:
j- Job for which some activities are launched.envs- Partially built environment variable map. Implementation of this method is expected to add additional variables here.listener- Connected to the build console. Can be used to report errors.- Throws:
IOExceptionInterruptedException- Since:
- 1.527
-
all
public static ExtensionList<EnvironmentContributor> all()
Returns all the registeredEnvironmentContributors.
-
-