N
- NodeProperty
can choose to only work with a certain subtype of Node
, and this 'N'
represents that type. Also see PropertyDescriptor.isApplicable(Class)
.public abstract class NodeProperty<N extends Node> extends Object implements ReconfigurableDescribable<NodeProperty<?>>, ExtensionPoint
Node
.
Plugins can contribute this extension point to add additional data to Node
.
NodeProperty
s show up in the configuration screen of a node, and they are persisted with the Node
object.
To add UI action to Node
s, i.e. a new link shown in the left side menu on a node page (./computer/<a node>
), see instead TransientComputerActionFactory
.
Computer
associated with the node
ExtensionPoint.LegacyInstancesAreScopedToHudson
Constructor and Description |
---|
NodeProperty() |
Modifier and Type | Method and Description |
---|---|
static DescriptorExtensionList<NodeProperty<?>,NodePropertyDescriptor> |
all()
Lists up all the registered
NodeDescriptor s in the system. |
void |
buildEnvVars(EnvVars env,
TaskListener listener)
Creates environment variable override for launching child processes in this node.
|
CauseOfBlockage |
canTake(Queue.BuildableItem item)
Called by the
Node to help determine whether or not it should
take the given task. |
CauseOfBlockage |
canTake(Queue.Task task)
Deprecated.
as of 1.413
Use
canTake(Queue.BuildableItem) |
static List<NodePropertyDescriptor> |
for_(Node node)
List up all
NodePropertyDescriptor s that are applicable for the
given project. |
NodePropertyDescriptor |
getDescriptor()
Gets the descriptor for this instance.
|
NodeProperty<?> |
reconfigure(org.kohsuke.stapler.StaplerRequest req,
net.sf.json.JSONObject form)
When a parent/owner object of a Describable gets a config form submission and instances are
recreated, this method is invoked on the existing instance (meaning the 'this' reference
points to the existing instance) to create a new instance to be added to the parent/owner object.
|
protected void |
setNode(N node) |
Environment |
setUp(AbstractBuild build,
Launcher launcher,
BuildListener listener)
Runs before the
SCM.checkout(AbstractBuild, Launcher, FilePath, BuildListener, File) runs, and performs a set up. |
protected void setNode(N node)
public NodePropertyDescriptor getDescriptor()
Describable
Descriptor
is a singleton for every concrete Describable
implementation, so if a.getClass() == b.getClass()
then by default
a.getDescriptor() == b.getDescriptor()
as well.
(In rare cases a single implementation class may be used for instances with distinct descriptors.)
getDescriptor
in interface Describable<NodeProperty<?>>
@Deprecated public CauseOfBlockage canTake(Queue.Task task)
canTake(Queue.BuildableItem)
Node
to help determine whether or not it should
take the given task. Individual properties can return a non-null value
here if there is some reason the given task should not be run on its
associated node. By default, this method returns null
.public CauseOfBlockage canTake(Queue.BuildableItem item)
Node
to help determine whether or not it should
take the given task. Individual properties can return a non-null value
here if there is some reason the given task should not be run on its
associated node. By default, this method returns null
.public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException
SCM.checkout(AbstractBuild, Launcher, FilePath, BuildListener, File)
runs, and performs a set up.
Can contribute additional properties to the environment.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(@NonNull EnvVars env, @NonNull TaskListener listener) throws IOException, InterruptedException
Whereas 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 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 setUp(AbstractBuild, Launcher, BuildListener)
.
Unfortunately, Jenkins core earlier than 1.488 only calls setUp(AbstractBuild, Launcher, BuildListener)
,
so if the backward compatibility with these earlier versions is important, implementations
should invoke this method from Environment.buildEnvVars(Map)
.
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
public NodeProperty<?> reconfigure(org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject form) throws Descriptor.FormException
ReconfigurableDescribable
The default implementation of this should be the following:
return form==null ? null : getDescriptor().newInstance(req, form);
reconfigure
in interface ReconfigurableDescribable<NodeProperty<?>>
req
- The current HTTP request being processed.form
- JSON fragment that corresponds to this describable object.
If the newly submitted form doesn't include a fragment for this describable
(meaning the user has de-selected your descriptor), then this argument is null.Descriptor.FormException
public static DescriptorExtensionList<NodeProperty<?>,NodePropertyDescriptor> all()
NodeDescriptor
s in the system.public static List<NodePropertyDescriptor> for_(Node node)
NodePropertyDescriptor
s that are applicable for the
given project.Copyright © 2004–2022. All rights reserved.