Class SSHLauncher

    • Field Detail

      • 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
      • 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 Detail

      • 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 Detail

      • 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()
      • 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).
      • getCredentialsId

        public String getCredentialsId()
      • 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:
        JENKINS-49235
      • 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()