Class SSHLauncher

All Implemented Interfaces:
ExtensionPoint, Describable<ComputerLauncher>

public class SSHLauncher extends ComputerLauncher
A computer launcher that tries to start a linux agent by opening an SSH connection and trying to find java.
  • Field Details

    • SSH_SCHEME

      public static final com.cloudbees.plugins.credentials.domains.SchemeRequirement SSH_SCHEME
      The scheme requirement.
    • DEFAULT_MAX_NUM_RETRIES

      public static final Integer DEFAULT_MAX_NUM_RETRIES
    • DEFAULT_RETRY_WAIT_TIME

      public static final Integer DEFAULT_RETRY_WAIT_TIME
    • DEFAULT_LAUNCH_TIMEOUT_SECONDS

      public static final Integer DEFAULT_LAUNCH_TIMEOUT_SECONDS
    • AGENT_JAR

      public static final String AGENT_JAR
      See Also:
    • SLASH_AGENT_JAR

      public static final String SLASH_AGENT_JAR
      See Also:
    • WORK_DIR_PARAM

      public static final String WORK_DIR_PARAM
      See Also:
    • JAR_CACHE_PARAM

      public static final String JAR_CACHE_PARAM
      See Also:
    • JAR_CACHE_DIR

      public static final String JAR_CACHE_DIR
      See Also:
    • DEFAULT_SSH_PORT

      public static final int DEFAULT_SSH_PORT
      See Also:
    • javaPath

      public String javaPath
      Field javaPath.
    • prefixStartSlaveCmd

      public String prefixStartSlaveCmd
      Field prefixStartSlaveCmd.
    • suffixStartSlaveCmd

      public String suffixStartSlaveCmd
      Field suffixStartSlaveCmd.
    • launchTimeoutSeconds

      public Integer launchTimeoutSeconds
      Field launchTimeoutSeconds.
    • maxNumRetries

      public Integer maxNumRetries
      Field maxNumRetries.
    • retryWaitTime

      public Integer 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. If null 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 seconds
      maxNumRetries - The number of times to retry connection if the SSH connection is refused during initial connect
      retryWaitTime - The number of seconds to wait between retries
      sshHostKeyVerificationStrategy - Host key verification method selected.
    • SSHLauncher

      @DataBoundConstructor public SSHLauncher(@NonNull String host, int port, String credentialsId)
      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

      public Object readResolve()
    • getCredentials

      public com.cloudbees.plugins.credentials.common.StandardUsernameCredentials getCredentials()
    • isLaunchSupported

      public boolean isLaunchSupported()
      Overrides:
      isLaunchSupported in class ComputerLauncher
    • getJvmOptions

      public String 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 public String 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

      @CheckForNull public static String getWorkingDirectory(SlaveComputer computer)
      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

      public void launch(SlaveComputer computer, TaskListener listener) throws InterruptedException
      Overrides:
      launch in class ComputerLauncher
      Throws:
      InterruptedException
    • reportEnvironment

      protected void reportEnvironment(TaskListener listener) throws IOException, InterruptedException
      Throws:
      IOException
      InterruptedException
    • openConnection

      protected void openConnection(TaskListener listener, SlaveComputer computer) throws IOException, InterruptedException
      Throws:
      IOException
      InterruptedException
    • afterDisconnect

      public void afterDisconnect(SlaveComputer slaveComputer, TaskListener listener)
      Overrides:
      afterDisconnect in class ComputerLauncher
    • getCredentialsId

      public String getCredentialsId()
    • getSshHostKeyVerificationStrategy

      @CheckForNull public SshHostKeyVerificationStrategy getSshHostKeyVerificationStrategy()
    • setSshHostKeyVerificationStrategy

      @DataBoundSetter public void setSshHostKeyVerificationStrategy(@CheckForNull SshHostKeyVerificationStrategy value)
    • setJvmOptions

      @DataBoundSetter public void setJvmOptions(String value)
    • setJavaPath

      @DataBoundSetter public void setJavaPath(String value)
    • setPrefixStartSlaveCmd

      @DataBoundSetter public void setPrefixStartSlaveCmd(String value)
    • setSuffixStartSlaveCmd

      @DataBoundSetter public void setSuffixStartSlaveCmd(String value)
    • setMaxNumRetries

      @DataBoundSetter public void setMaxNumRetries(Integer value)
    • setLaunchTimeoutSeconds

      @DataBoundSetter public void setLaunchTimeoutSeconds(Integer value)
    • setRetryWaitTime

      @DataBoundSetter public void setRetryWaitTime(Integer value)
    • setPort

      public void setPort(int value)
    • setHost

      public void setHost(String value)
    • getHost

      public String 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

      @NonNull public String getPrefixStartSlaveCmd()
    • getSuffixStartSlaveCmd

      @NonNull public String getSuffixStartSlaveCmd()
    • getLaunchTimeoutSeconds

      @NonNull public Integer getLaunchTimeoutSeconds()
      Getter for property 'launchTimeoutSeconds'
      Returns:
      launchTimeoutSeconds
    • getMaxNumRetries

      @NonNull public Integer getMaxNumRetries()
      Getter for property 'maxNumRetries'
      Returns:
      maxNumRetries
    • getRetryWaitTime

      @NonNull public Integer 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

      public String getWorkDir()
    • setWorkDir

      @DataBoundSetter public void setWorkDir(String workDir)
    • 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

      public String logConfiguration()