Package hudson.slaves

Class NodeProperty<N extends Node>

Type Parameters:
N - NodeProperty can choose to only work with a certain subtype of Node, and this 'N' represents that type. Also see PropertyDescriptor.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 of Node.

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 the Node object.

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 instead TransientComputerActionFactory.


Added to the configuration page of the node.
Added to the system configuration page.
summary.jelly (optional)
Added to the index page of the Computer associated with the node
  • Field Details

    • node

      protected transient N extends Node node
  • Constructor Details

    • NodeProperty

      public NodeProperty()
  • Method Details

    • setNode

      protected void setNode(N node)
    • getDescriptor

      public NodePropertyDescriptor getDescriptor()
      Description copied from interface: Describable
      Gets the descriptor for this instance.

      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.)

      Specified by:
      getDescriptor in interface Describable<N extends Node>
    • canTake

      @Deprecated public CauseOfBlockage canTake(Queue.Task task)
      Called by the 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.
    • canTake

      public CauseOfBlockage canTake(Queue.BuildableItem item)
      Called by the 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.
    • setUp

      public Environment setUp(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException
      Runs before the 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.
      non-null if the build can continue, null if there was an error and the build needs to be aborted.
      IOException - terminates the build abnormally. Hudson will handle the exception and reports a nice error message.
    • buildEnvVars

      public void buildEnvVars(@NonNull EnvVars env, @NonNull TaskListener listener) throws IOException, InterruptedException
      Creates 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 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.
    • reconfigure

      public NodeProperty<?> reconfigure(org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject form) throws Descriptor.FormException
      Description copied from interface: ReconfigurableDescribable
      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.

      The default implementation of this should be the following:

       return form==null ? null : getDescriptor().newInstance(req, form);
      Specified by:
      reconfigure in interface ReconfigurableDescribable<N extends Node>
      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.
      The new instance. To not to create an instance of a describable, return null.
    • all

      Lists up all the registered NodeDescriptors in the system.
    • for_

      public static List<NodePropertyDescriptor> for_(Node node)
      List up all NodePropertyDescriptors that are applicable for the given project.