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.console.ConsoleLogFilter |
LOG_FILTER
We listen to loggers creation by $
Run s so we can write the executor's launch log into build log. |
Constructor and Description |
---|
OneShotSlave(hudson.model.Queue.BuildableItem item,
String nodeDescription,
String remoteFS,
hudson.slaves.ComputerLauncher launcher) |
Modifier and Type | Method and Description |
---|---|
OneShotSlave |
asNode() |
hudson.model.Computer |
createComputer() |
hudson.Launcher |
createLauncher(hudson.model.TaskListener listener)
Pipeline does not use the same mecanism to use nodes, so we also need to consider $
createLauncher(TaskListener)
as an event to determine first use of the slave. |
OneShotComputer |
getComputer() |
String |
getNodeDescription() |
int |
getNumExecutors() |
protected boolean |
hasExecutable() |
protected void |
provision() |
void |
setComputerListener(hudson.model.TaskListener computerListener)
Assign the $
ComputerLauncher listener as the node is actually started, so we can pipe it to the
$Run log. |
void |
setExecutable(hudson.model.Queue.Executable executable)
Assign a $
Run to this OneShotSlave. |
equals, getClockDifferenceCallable, getDescriptor, getLabelString, getLauncher, getMode, getNodeName, getNodeProperties, getRemoteFS, getRetentionStrategy, getRootPath, getUserId, getWorkspaceFor, getWorkspaceRoot, hashCode, readResolve, setLabelString, setLauncher, setMode, setNodeName, setRetentionStrategy, setUserId, toString
canTake, canTake, checkPermission, createPath, getACL, getAssignedLabels, getChannel, getClockDifference, getDisplayName, getFileSystemProvisioner, getLabelCloud, getNodePropertyDescriptors, getSearchUrl, getSelfLabel, hasPermission, isAcceptingTasks, isHoldOffLaunchUntilSave, reconfigure, toComputer
@Extension public static final hudson.console.ConsoleLogFilter LOG_FILTER
Run
s so we can write the executor's launch log into build log.public OneShotSlave(hudson.model.Queue.BuildableItem item, String nodeDescription, String remoteFS, hudson.slaves.ComputerLauncher launcher) throws hudson.model.Descriptor.FormException, IOException
hudson.model.Descriptor.FormException
IOException
public String getNodeDescription()
getNodeDescription
in class hudson.model.Slave
public hudson.model.Computer createComputer()
createComputer
in class hudson.model.Slave
public int getNumExecutors()
getNumExecutors
in class hudson.model.Slave
public void setComputerListener(hudson.model.TaskListener computerListener)
ComputerLauncher
listener as the node is actually started, so we can pipe it to the
$Run
log. We need this as we can't just use getComputer().getListener()
OneShotComputer.COMPUTER_LISTENER
protected boolean hasExecutable()
public OneShotComputer getComputer()
getComputer
in class hudson.model.Slave
protected void provision()
public void setExecutable(hudson.model.Queue.Executable executable)
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. It run the actual launch of the executor
and collect it's log so we can pipe it to the Run's $BuildListener
(which is created later).
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 hudson.Launcher createLauncher(hudson.model.TaskListener listener)
createLauncher(TaskListener)
as an event to determine first use of the slave.createLauncher
in class hudson.model.Slave
public OneShotSlave asNode()
asNode
in interface hudson.slaves.EphemeralNode
Copyright © 2016. All rights reserved.