public class EnvironmentVariablesNodeProperty extends NodeProperty<Node>
NodeProperty
that sets additional environment variables.Modifier and Type | Class and Description |
---|---|
static class |
EnvironmentVariablesNodeProperty.DescriptorImpl |
static class |
EnvironmentVariablesNodeProperty.Entry |
ExtensionPoint.LegacyInstancesAreScopedToHudson
node
Constructor and Description |
---|
EnvironmentVariablesNodeProperty(EnvironmentVariablesNodeProperty.Entry... env) |
EnvironmentVariablesNodeProperty(List<EnvironmentVariablesNodeProperty.Entry> env) |
Modifier and Type | Method and Description |
---|---|
void |
buildEnvVars(EnvVars env,
TaskListener listener)
Creates environment variable override for launching child processes in this node.
|
List<EnvironmentVariablesNodeProperty.Entry> |
getEnv() |
EnvVars |
getEnvVars() |
Environment |
setUp(AbstractBuild build,
Launcher launcher,
BuildListener listener)
Runs before the
SCM.checkout(AbstractBuild, Launcher, FilePath, BuildListener, File) runs, and performs a set up. |
all, canTake, canTake, for_, getDescriptor, reconfigure, setNode
@DataBoundConstructor public EnvironmentVariablesNodeProperty(List<EnvironmentVariablesNodeProperty.Entry> env)
public EnvironmentVariablesNodeProperty(EnvironmentVariablesNodeProperty.Entry... env)
public EnvVars getEnvVars()
public List<EnvironmentVariablesNodeProperty.Entry> getEnv()
public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException
NodeProperty
SCM.checkout(AbstractBuild, Launcher, FilePath, BuildListener, File)
runs, and performs a set up.
Can contribute additional properties to the environment.setUp
in class NodeProperty<Node>
build
- The build in progress for which an Environment
object is created.
Never null.launcher
- This launcher can be used to launch processes for this build.
If the build runs remotely, launcher will also run a job on that remote machine.
Never null.listener
- Can be used to send any message.IOException
- terminates the build abnormally. Hudson will handle the exception
and reports a nice error message.InterruptedException
public void buildEnvVars(EnvVars env, TaskListener listener) throws IOException, InterruptedException
NodeProperty
Whereas NodeProperty.setUp(AbstractBuild, Launcher, BuildListener)
is used specifically for
executing builds, this method is used for other process launch activities that happens
outside the context of a build, such as polling, one time action (tagging, deployment, etc.)
Starting 1.489, this method and NodeProperty.setUp(AbstractBuild, Launcher, BuildListener)
are
layered properly. That is, for launching processes for a build, this method
is called first and then Environment.buildEnvVars(Map)
will be added on top.
This allows implementations to put node-scoped environment variables here, then
build scoped variables to NodeProperty.setUp(AbstractBuild, Launcher, BuildListener)
.
Unfortunately, Jenkins core earlier than 1.488 only calls NodeProperty.setUp(AbstractBuild, Launcher, BuildListener)
,
so if the backward compatibility with these earlier versions is important, implementations
should invoke this method from Environment.buildEnvVars(Map)
.
buildEnvVars
in class NodeProperty<Node>
env
- Manipulate this variable (normally by adding more entries.)
Note that this is an override, so it doesn't contain environment variables that are
currently set for the agent process itself.listener
- Can be used to send messages.IOException
InterruptedException
Copyright © 2004–2021. All rights reserved.