public class OneShotSlave
extends hudson.model.Slave
implements hudson.slaves.EphemeralNode
Run, and as such has a life cycle
 to fully match the Run's one.
 
 Provisioning such a slave should be a lightweight process, so one can provision them at any time and concurrently
 to match $Queue load. Typical usage is Docker container based Jenkins agents.
 
 Actual launch of the Slave is postponed until a $Run is created, so we can have a 1:1 match between Run and
 Executor lifecycle:
 
Result.NOT_BUILT on launch failure.hudson.model.Slave.JnlpJar, hudson.model.Slave.SlaveDescriptor| Modifier and Type | Field and Description | 
|---|---|
| static hudson.model.queue.CauseOfBlockage | BecauseNodeIsDedicatedBuild is blocked because node is dedicated to another queue item | 
| Constructor and Description | 
|---|
| OneShotSlave(hudson.model.Queue.BuildableItem queueItem,
            String nodeDescription,
            String remoteFS,
            hudson.slaves.ComputerLauncher launcher,
            Charset charset) | 
| Modifier and Type | Method and Description | 
|---|---|
| OneShotSlave | asNode() | 
| hudson.model.queue.CauseOfBlockage | canTake(hudson.model.Queue.BuildableItem item) | 
| OneShotComputer | createComputer() | 
| hudson.Launcher | createLauncher(hudson.model.TaskListener listener)Pipeline does not use the same mechanism to use nodes, so we also need to consider $ createLauncher(TaskListener)as an event to determine first use of the slave. see https://issues.jenkins-ci.org/browse/JENKINS-35521 | 
| protected void | doActualLaunch(hudson.model.TaskListener listener) | 
| protected Charset | getCharset() | 
| OneShotComputer | getComputer() | 
| String | getDisplayName() | 
| String | getNodeDescription() | 
| int | getNumExecutors() | 
| long | getQueueItemId() | 
| protected boolean | hasExecutable() | 
| void | setExecutable()Set executable based on current Executor activity. | 
| void | setExecutable(hudson.model.Run run)Assign a $ Runto this OneShotSlave. | 
equals, getClockDifferenceCallable, getDescriptor, getLabelString, getLauncher, getMode, getNodeName, getNodeProperties, getRemoteFS, getRetentionStrategy, getRootPath, getUserId, getWorkspaceFor, getWorkspaceRoot, hashCode, readResolve, setLabelString, setLauncher, setMode, setNodeDescription, setNodeName, setNodeProperties, setNumExecutors, setRetentionStrategy, setUserId, toStringcanTake, checkPermission, createPath, getACL, getAssignedLabels, getChannel, getClockDifference, getFileSystemProvisioner, getLabelCloud, getNodePropertyDescriptors, getSearchUrl, getSelfLabel, hasPermission, isAcceptingTasks, isHoldOffLaunchUntilSave, reconfigure, save, toComputerpublic static final hudson.model.queue.CauseOfBlockage BecauseNodeIsDedicated
public OneShotSlave(hudson.model.Queue.BuildableItem queueItem,
                    String nodeDescription,
                    String remoteFS,
                    hudson.slaves.ComputerLauncher launcher,
                    Charset charset)
             throws hudson.model.Descriptor.FormException,
                    IOException
queueItem - The Queue.Item this slave is assigned tonodeDescription - Node description for UIremoteFS - agent working directorylauncher - ComputerLauncher used to bootstrap this slave.charset - Computer's Charset. Need to be set by caller as we can't determine this one before actual launch.Descriptor.FormExceptionIOExceptionpublic hudson.model.queue.CauseOfBlockage canTake(hudson.model.Queue.BuildableItem item)
canTake in class hudson.model.Nodepublic String getDisplayName()
getDisplayName in interface hudson.model.ModelObjectgetDisplayName in class hudson.model.Nodepublic String getNodeDescription()
getNodeDescription in class hudson.model.Slavepublic long getQueueItemId()
protected Charset getCharset()
public OneShotComputer createComputer()
createComputer in class hudson.model.Slavepublic int getNumExecutors()
getNumExecutors in class hudson.model.Slaveprotected boolean hasExecutable()
public OneShotComputer getComputer()
getComputer in class hudson.model.Slavepublic void setExecutable(hudson.model.Run run)
Run to this OneShotSlave. By design, only one Run can be assigned, then slave is shut down.
 This method has to be called just as the $Run as been created, typically relying on
 RunListener.fireFinalized(Run) event. It run the actual launch of the executor
 and collect it's log into the the Run's $BuildListener.
 Delaying launch of the executor until the Run is actually started allows to fail the build on launch failure, so we have a strong 1:1 relation between a Run and it's Executor.
public void setExecutable()
protected void doActualLaunch(hudson.model.TaskListener listener)
public hudson.Launcher createLauncher(hudson.model.TaskListener listener)
createLauncher(TaskListener)
 as an event to determine first use of the slave. see https://issues.jenkins-ci.org/browse/JENKINS-35521createLauncher in class hudson.model.Slavepublic OneShotSlave asNode()
asNode in interface hudson.slaves.EphemeralNodeCopyright © 2016–2017. All rights reserved.