Package hudson.plugins.sshslaves
Class SSHLauncher
java.lang.Object
hudson.model.AbstractDescribableImpl<ComputerLauncher>
hudson.slaves.ComputerLauncher
hudson.plugins.sshslaves.SSHLauncher
- All Implemented Interfaces:
ExtensionPoint
,Describable<ComputerLauncher>
A computer launcher that tries to start a linux agent by opening an SSH connection and trying to find java.
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final Integer
static final Integer
static final Integer
static final int
static final String
static final String
Field javaPath.Field launchTimeoutSeconds.Field maxNumRetries.Field prefixStartSlaveCmd.Field retryWaitTime (seconds).static final String
static final com.cloudbees.plugins.credentials.domains.SchemeRequirement
The scheme requirement.Field suffixStartSlaveCmd.static final String
Fields inherited from class hudson.slaves.ComputerLauncher
LIST
-
Constructor Summary
ConstructorDescriptionSSHLauncher
(String host, int port, String credentialsId) Constructor SSHLauncher creates a new SSHLauncher instance.SSHLauncher
(String host, int port, String credentialsId, String jvmOptions, String javaPath, String prefixStartSlaveCmd, String suffixStartSlaveCmd, Integer launchTimeoutSeconds, Integer maxNumRetries, Integer retryWaitTime, SshHostKeyVerificationStrategy sshHostKeyVerificationStrategy) Constructor SSHLauncher creates a new SSHLauncher instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
afterDisconnect
(SlaveComputer slaveComputer, TaskListener listener) com.trilead.ssh2.Connection
com.cloudbees.plugins.credentials.common.StandardUsernameCredentials
getHost()
Getter for property 'host'.Deprecated.Gets the optional JVM Options used to launch the agent JVM.Getter for property 'launchTimeoutSeconds'Getter for property 'maxNumRetries'int
getPort()
Getter for property 'port'.Getter for property 'retryWaitTime'boolean
static String
Gets the formatted current time stamp.boolean
Enable/Disable the credential tracking, this tracking store information about where it is used a credential, in this case in a node.getWorkDirParam
(String workingDirectory) static String
getWorkingDirectory
(SlaveComputer computer) Returns the remote root workspace (without trailing slash).boolean
void
launch
(SlaveComputer computer, TaskListener listener) static com.cloudbees.plugins.credentials.common.StandardUsernameCredentials
lookupSystemCredentials
(String credentialsId) protected void
openConnection
(TaskListener listener, SlaveComputer computer) protected void
reportEnvironment
(TaskListener listener) void
void
setJavaPath
(String value) void
setJvmOptions
(String value) void
setLaunchTimeoutSeconds
(Integer value) void
setMaxNumRetries
(Integer value) void
setPort
(int value) void
setPrefixStartSlaveCmd
(String value) void
setRetryWaitTime
(Integer value) void
void
setSuffixStartSlaveCmd
(String value) void
setTcpNoDelay
(boolean tcpNoDelay) void
setWorkDir
(String workDir) Methods inherited from class hudson.slaves.ComputerLauncher
afterDisconnect, beforeDisconnect, beforeDisconnect, checkJavaVersion, launch
Methods inherited from class hudson.model.AbstractDescribableImpl
getDescriptor
-
Field Details
-
SSH_SCHEME
public static final com.cloudbees.plugins.credentials.domains.SchemeRequirement SSH_SCHEMEThe scheme requirement. -
DEFAULT_MAX_NUM_RETRIES
-
DEFAULT_RETRY_WAIT_TIME
-
DEFAULT_LAUNCH_TIMEOUT_SECONDS
-
AGENT_JAR
- See Also:
-
SLASH_AGENT_JAR
- See Also:
-
WORK_DIR_PARAM
- See Also:
-
JAR_CACHE_PARAM
- See Also:
-
JAR_CACHE_DIR
- See Also:
-
DEFAULT_SSH_PORT
public static final int DEFAULT_SSH_PORT- See Also:
-
javaPath
Field javaPath. -
prefixStartSlaveCmd
Field prefixStartSlaveCmd. -
suffixStartSlaveCmd
Field suffixStartSlaveCmd. -
launchTimeoutSeconds
Field launchTimeoutSeconds. -
maxNumRetries
Field maxNumRetries. -
retryWaitTime
Field retryWaitTime (seconds).
-
-
Constructor Details
-
SSHLauncher
public SSHLauncher(@NonNull String host, int port, String credentialsId, String jvmOptions, String javaPath, String prefixStartSlaveCmd, String suffixStartSlaveCmd, Integer launchTimeoutSeconds, Integer maxNumRetries, Integer retryWaitTime, @CheckForNull SshHostKeyVerificationStrategy sshHostKeyVerificationStrategy) Constructor SSHLauncher creates a new SSHLauncher instance.- Parameters:
host
- The host to connect to.port
- The port to connect on.credentialsId
- The credentials id to connect as.jvmOptions
- Options passed to the java vm.javaPath
- Path to the host jdk installation. Ifnull
the jdk will be auto detected.prefixStartSlaveCmd
- This will prefix the start agent command. For instance if you want to execute the command with a different shell.suffixStartSlaveCmd
- This will suffix the start agent command.launchTimeoutSeconds
- Launch timeout in secondsmaxNumRetries
- The number of times to retry connection if the SSH connection is refused during initial connectretryWaitTime
- The number of seconds to wait between retriessshHostKeyVerificationStrategy
- Host key verification method selected.
-
SSHLauncher
Constructor SSHLauncher creates a new SSHLauncher instance.- Parameters:
host
- The host to connect to.port
- The port to connect on.credentialsId
- The credentials id to connect as.
-
-
Method Details
-
lookupSystemCredentials
public static com.cloudbees.plugins.credentials.common.StandardUsernameCredentials lookupSystemCredentials(String credentialsId) -
readResolve
-
getCredentials
public com.cloudbees.plugins.credentials.common.StandardUsernameCredentials getCredentials() -
isLaunchSupported
public boolean isLaunchSupported()- Overrides:
isLaunchSupported
in classComputerLauncher
-
getJvmOptions
Gets the optional JVM Options used to launch the agent JVM.- Returns:
- The optional JVM Options used to launch the agent JVM.
-
getJavaPath
Deprecated.Gets the optional java command to use to launch the agent JVM.- Returns:
- The optional java command to use to launch the agent JVM.
-
getTimestamp
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public static String getTimestamp()Gets the formatted current time stamp.- Returns:
- the formatted current time stamp.
-
getWorkingDirectory
Returns the remote root workspace (without trailing slash).- Parameters:
computer
- The computer to get the root workspace of.- Returns:
- the remote root workspace (without trailing slash).
-
launch
- Overrides:
launch
in classComputerLauncher
- Throws:
InterruptedException
-
reportEnvironment
- Throws:
IOException
InterruptedException
-
openConnection
protected void openConnection(TaskListener listener, SlaveComputer computer) throws IOException, InterruptedException - Throws:
IOException
InterruptedException
-
afterDisconnect
- Overrides:
afterDisconnect
in classComputerLauncher
-
getCredentialsId
-
getSshHostKeyVerificationStrategy
-
setSshHostKeyVerificationStrategy
@DataBoundSetter public void setSshHostKeyVerificationStrategy(@CheckForNull SshHostKeyVerificationStrategy value) -
setJvmOptions
-
setJavaPath
-
setPrefixStartSlaveCmd
-
setSuffixStartSlaveCmd
-
setMaxNumRetries
-
setLaunchTimeoutSeconds
-
setRetryWaitTime
-
setPort
public void setPort(int value) -
setHost
-
getHost
Getter for property 'host'.- Returns:
- Value for property 'host'.
-
getPort
public int getPort()Getter for property 'port'.- Returns:
- Value for property 'port'.
-
getConnection
public com.trilead.ssh2.Connection getConnection() -
getPrefixStartSlaveCmd
-
getSuffixStartSlaveCmd
-
getLaunchTimeoutSeconds
Getter for property 'launchTimeoutSeconds'- Returns:
- launchTimeoutSeconds
-
getMaxNumRetries
Getter for property 'maxNumRetries'- Returns:
- maxNumRetries
-
getRetryWaitTime
Getter for property 'retryWaitTime'- Returns:
- retryWaitTime
-
getTcpNoDelay
public boolean getTcpNoDelay() -
setTcpNoDelay
@DataBoundSetter public void setTcpNoDelay(boolean tcpNoDelay) -
getTrackCredentials
public boolean getTrackCredentials()Enable/Disable the credential tracking, this tracking store information about where it is used a credential, in this case in a node. If the tracking is enabled and you launch a big number of Agents per day, activate credentials tacking could cause a performance issue see- See Also:
-
getWorkDir
-
setWorkDir
-
getWorkDirParam
@NonNull @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public String getWorkDirParam(@NonNull String workingDirectory) - Parameters:
workingDirectory
- The Working directory set on the configuration of the node.- Returns:
- the remoting parameter to set the workDir, by default it is the same as the working directory configured on the node so "-workDir " + workingDirectory, if workDir is set, he method will return "-workDir " + getWorkDir() if the parameter is set in suffixStartSlaveCmd, the method will return an empty String.
-
logConfiguration
-