hudson.slaves
Class NodeProperty<N extends Node>

java.lang.Object
  extended by hudson.slaves.NodeProperty<N>
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:
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 or UI actions to Node. NodePropertys show up in the configuration screen of a node, and they are persisted with the Node object.

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 Computer associated with the node

Since:
1.286

Nested Class Summary
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Field Summary
protected  N node
           
 
Constructor Summary
NodeProperty()
           
 
Method Summary
static DescriptorExtensionList<NodeProperty<?>,NodePropertyDescriptor> all()
          Lists up all the registered NodeDescriptors 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(BuildableItem)
static List<NodePropertyDescriptor> for_(Node node)
          List up all NodePropertyDescriptors 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

node

protected transient N extends Node node
Constructor Detail

NodeProperty

public NodeProperty()
Method Detail

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 a.getDescriptor()==b.getDescriptor() must hold.

Specified by:
getDescriptor in interface Describable<NodeProperty<?>>

canTake

public CauseOfBlockage canTake(Queue.Task task)
Deprecated. as of 1.413 Use #canTake(BuildableItem)

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.

Since:
1.360

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.

Since:
1.413

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.

Parameters:
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.
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(EnvVars env,
                         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).

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 slave process itself.
listener - Can be used to send messages.
Throws:
IOException
InterruptedException
Since:
1.489

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<NodeProperty<?>>
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 registered NodeDescriptors in the system.


for_

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



Copyright © 2004-2013. All Rights Reserved.