Class NodeProperty<N extends Node>
- java.lang.Object
-
- hudson.slaves.NodeProperty<N>
-
- Type Parameters:
N-NodePropertycan choose to only work with a certain subtype ofNode, and this 'N' represents that type. Also seePropertyDescriptor.isApplicable(Class).
- All Implemented Interfaces:
ExtensionPoint,Describable<NodeProperty<?>>,ReconfigurableDescribable<NodeProperty<?>>
- Direct Known Subclasses:
DiskSpaceMonitorNodeProperty,EnvironmentVariablesNodeProperty,ToolLocationNodeProperty
public abstract class NodeProperty<N extends Node> extends Object implements ReconfigurableDescribable<NodeProperty<?>>, ExtensionPoint
Extensible property ofNode.Plugins can contribute this extension point to add additional data to
Node.NodePropertys show up in the configuration screen of a node, and they are persisted with theNodeobject.To add UI action to
Nodes, i.e. a new link shown in the left side menu on a node page (./computer/<a node>), see insteadTransientComputerActionFactory.Views
- config.jelly
- Added to the configuration page of the node.
- global.jelly
- Added to the system configuration page.
- summary.jelly (optional)
- Added to the index page of the
Computerassociated with the node
- Since:
- 1.286
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description NodeProperty()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static DescriptorExtensionList<NodeProperty<?>,NodePropertyDescriptor>all()Lists up all the registeredNodeDescriptors in the system.voidbuildEnvVars(EnvVars env, TaskListener listener)Creates environment variable override for launching child processes in this node.CauseOfBlockagecanTake(Queue.BuildableItem item)Called by theNodeto help determine whether or not it should take the given task.CauseOfBlockagecanTake(Queue.Task task)Deprecated.as of 1.413 UsecanTake(Queue.BuildableItem)static List<NodePropertyDescriptor>for_(Node node)List up allNodePropertyDescriptors that are applicable for the given project.NodePropertyDescriptorgetDescriptor()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 voidsetNode(N node)EnvironmentsetUp(AbstractBuild build, Launcher launcher, BuildListener listener)Runs before theSCM.checkout(AbstractBuild, Launcher, FilePath, BuildListener, File)runs, and performs a set up.
-
-
-
Method Detail
-
setNode
protected void setNode(N node)
-
getDescriptor
public NodePropertyDescriptor getDescriptor()
Description copied from interface:DescribableGets the descriptor for this instance.Descriptoris a singleton for every concreteDescribableimplementation, so ifa.getClass() == b.getClass()then by defaulta.getDescriptor() == b.getDescriptor()as well. (In rare cases a single implementation class may be used for instances with distinct descriptors.)- Specified by:
getDescriptorin interfaceDescribable<N extends Node>
-
canTake
@Deprecated public CauseOfBlockage canTake(Queue.Task task)
Deprecated.as of 1.413 UsecanTake(Queue.BuildableItem)Called by theNodeto 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 returnsnull.- Since:
- 1.360
-
canTake
public CauseOfBlockage canTake(Queue.BuildableItem item)
Called by theNodeto 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 returnsnull.- Since:
- 1.413
-
setUp
public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException
Runs before theSCM.checkout(AbstractBuild, Launcher, FilePath, BuildListener, File)runs, and performs a set up. Can contribute additional properties to the environment.- Parameters:
build- The build in progress for which anEnvironmentobject 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.- Returns:
- non-null if the build can continue, null if there was an error and the build needs to be aborted.
- Throws:
IOException- terminates the build abnormally. Hudson will handle the exception and reports a nice error message.InterruptedException
-
buildEnvVars
public void buildEnvVars(@NonNull EnvVars env, @NonNull TaskListener listener) throws IOException, InterruptedExceptionCreates environment variable override for launching child processes in this node.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 thenEnvironment.buildEnvVars(Map)will be added on top. This allows implementations to put node-scoped environment variables here, then build scoped variables tosetUp(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 fromEnvironment.buildEnvVars(Map).- Parameters:
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.- Throws:
IOExceptionInterruptedException- Since:
- 1.489
-
reconfigure
public NodeProperty<?> reconfigure(org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject form) throws Descriptor.FormException
Description copied from interface:ReconfigurableDescribableWhen 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.The default implementation of this should be the following:
return form==null ? null : getDescriptor().newInstance(req, form);
- Specified by:
reconfigurein interfaceReconfigurableDescribable<N extends Node>- Parameters:
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.- Returns:
- The new instance. To not to create an instance of a describable, return null.
- Throws:
Descriptor.FormException
-
all
public static DescriptorExtensionList<NodeProperty<?>,NodePropertyDescriptor> all()
Lists up all the registeredNodeDescriptors in the system.
-
for_
public static List<NodePropertyDescriptor> for_(Node node)
List up allNodePropertyDescriptors that are applicable for the given project.
-
-