Class Environment
- Direct Known Subclasses:
BuildWrapper.Environment
This is often used to run a parallel server necessary during a build, such as an application server, a database reserved for the build, X server for performing UI tests, etc.
By having a plugin that does this, instead of asking each build script to do this,
we can simplify the build script. Environment
abstraction also gives
you guaranteed "tear down" phase, so that such resource won't keep running forever.
- Since:
- 1.286
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
buildEnvVars
(Map<String, String> env) Adds environmental variables for the builds to the given map.static Environment
CreatesEnvironment
implementation that just sets the variables as given in the parameter.boolean
tearDown
(AbstractBuild build, BuildListener listener) Runs after theBuilder
completes, and performs a tear down.
-
Constructor Details
-
Environment
public Environment()
-
-
Method Details
-
buildEnvVars
Adds environmental variables for the builds to the given map.If the
Environment
object wants to pass in information to the build that runs, it can do so by exporting additional environment variables to the map.When this method is invoked, the map already contains the current "planned export" list.
- Parameters:
env
- never null. This really should have been typed asEnvVars
but by the time we realized it it was too late.
-
tearDown
public boolean tearDown(AbstractBuild build, BuildListener listener) throws IOException, InterruptedException Runs after theBuilder
completes, and performs a tear down.This method is invoked even when the build failed, so that the clean up operation can be performed regardless of the build result (for example, you'll want to stop application server even if a build fails.)
- Parameters:
build
- The sameBuild
object given to the set up method.listener
- The sameBuildListener
object given to the set up method.- Returns:
- true if the build can continue, false if there was an error and the build needs to be failed.
- Throws:
IOException
- terminates the build abnormally. Jenkins will handle the exception and reports a nice error message.InterruptedException
-
create
CreatesEnvironment
implementation that just sets the variables as given in the parameter.
-