hudson.plugins.sshslaves
Class SSHLauncher

java.lang.Object
  extended by hudson.model.AbstractDescribableImpl<hudson.slaves.ComputerLauncher>
      extended by hudson.slaves.ComputerLauncher
          extended by hudson.plugins.sshslaves.SSHLauncher
All Implemented Interfaces:
hudson.ExtensionPoint, hudson.model.Describable<hudson.slaves.ComputerLauncher>

public class SSHLauncher
extends hudson.slaves.ComputerLauncher

A computer launcher that tries to start a linux slave by opening an SSH connection and trying to find java.


Nested Class Summary
static class SSHLauncher.DefaultJavaProvider
           
static class SSHLauncher.DefaultJDKInstaller
          Deprecated. Subtype of JDKInstaller causes JENKINS-10641.
static class SSHLauncher.DescriptorImpl
           
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Field Summary
 String javaPath
          Field javaPath.
 String prefixStartSlaveCmd
          Field prefixStartSlaveCmd.
 String suffixStartSlaveCmd
          Field suffixStartSlaveCmd.
 
Fields inherited from class hudson.slaves.ComputerLauncher
LIST
 
Constructor Summary
SSHLauncher(String host, int port, com.cloudbees.jenkins.plugins.sshcredentials.SSHUser credentials, String jvmOptions, String javaPath, hudson.tools.JDKInstaller jdkInstaller, String prefixStartSlaveCmd, String suffixStartSlaveCmd)
          Constructor SSHLauncher creates a new SSHLauncher instance.
SSHLauncher(String host, int port, com.cloudbees.jenkins.plugins.sshcredentials.SSHUser credentials, String jvmOptions, String javaPath, String prefixStartSlaveCmd, String suffixStartSlaveCmd)
          Constructor SSHLauncher creates a new SSHLauncher instance.
SSHLauncher(String host, int port, String username, String password, String privatekey, String jvmOptions)
           
SSHLauncher(String host, int port, String credentialsId, String jvmOptions, String javaPath, String prefixStartSlaveCmd, String suffixStartSlaveCmd)
          Constructor SSHLauncher creates a new SSHLauncher instance.
SSHLauncher(String host, int port, String username, String password, String privatekey, String jvmOptions, String javaPath, hudson.tools.JDKInstaller jdkInstaller, String prefixStartSlaveCmd, String suffixStartSlaveCmd)
          Deprecated. use the SSHUser based version
SSHLauncher(String host, int port, String username, String password, String privatekey, String jvmOptions, String javaPath, String prefixStartSlaveCmd, String suffixStartSlaveCmd)
          Deprecated. use the SSHUser based version
 
Method Summary
 void afterDisconnect(hudson.slaves.SlaveComputer slaveComputer, hudson.model.TaskListener listener)
          
protected  String checkJavaVersion(PrintStream logger, String javaCommand, BufferedReader r, StringWriter output)
          Given the output of "java -version" in r, determine if this version of Java is supported.
 com.trilead.ssh2.Connection getConnection()
           
 com.cloudbees.jenkins.plugins.sshcredentials.SSHUser getCredentials()
           
 String getCredentialsId()
           
 String getHost()
          Getter for property 'host'.
 String getJavaPath()
          Gets the optionnal java command to use to launch the slave JVM.
 String getJvmOptions()
          Gets the JVM Options used to launch the slave JVM.
 String getPassword()
          Deprecated.  
 int getPort()
          Getter for property 'port'.
 String getPrefixStartSlaveCmd()
           
 String getPrivatekey()
          Deprecated.  
 String getSuffixStartSlaveCmd()
           
protected  String getTimestamp()
          Gets the formatted current time stamp.
 String getUsername()
          Deprecated.  
 boolean isLaunchSupported()
          
 void launch(hudson.slaves.SlaveComputer computer, hudson.model.TaskListener listener)
          
static com.cloudbees.jenkins.plugins.sshcredentials.SSHUser lookupSystemCredentials(String credentialsId)
           
protected  void openConnection(hudson.model.TaskListener listener)
           
protected  void reportEnvironment(hudson.model.TaskListener listener)
           
protected  String resolveJava(hudson.slaves.SlaveComputer computer, hudson.model.TaskListener listener)
          return javaPath if specified in the configuration.
 
Methods inherited from class hudson.slaves.ComputerLauncher
afterDisconnect, beforeDisconnect, beforeDisconnect, launch
 
Methods inherited from class hudson.model.AbstractDescribableImpl
getDescriptor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

javaPath

public final String javaPath
Field javaPath.


prefixStartSlaveCmd

public final String prefixStartSlaveCmd
Field prefixStartSlaveCmd.


suffixStartSlaveCmd

public final String suffixStartSlaveCmd
Field suffixStartSlaveCmd.

Constructor Detail

SSHLauncher

@DataBoundConstructor
public SSHLauncher(String host,
                                        int port,
                                        String credentialsId,
                                        String jvmOptions,
                                        String javaPath,
                                        String prefixStartSlaveCmd,
                                        String suffixStartSlaveCmd)
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 or installed by the JDKInstaller.
prefixStartSlaveCmd - This will prefix the start slave command. For instance if you want to execute the command with a different shell.
suffixStartSlaveCmd - This will suffix the start slave command.

SSHLauncher

public SSHLauncher(String host,
                   int port,
                   com.cloudbees.jenkins.plugins.sshcredentials.SSHUser credentials,
                   String jvmOptions,
                   String javaPath,
                   String prefixStartSlaveCmd,
                   String suffixStartSlaveCmd)
Constructor SSHLauncher creates a new SSHLauncher instance.

Parameters:
host - The host to connect to.
port - The port to connect on.
credentials - The credentials 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 or installed by the JDKInstaller.
prefixStartSlaveCmd - This will prefix the start slave command. For instance if you want to execute the command with a different shell.
suffixStartSlaveCmd - This will suffix the start slave command.

SSHLauncher

@Deprecated
public SSHLauncher(String host,
                              int port,
                              String username,
                              String password,
                              String privatekey,
                              String jvmOptions,
                              String javaPath,
                              String prefixStartSlaveCmd,
                              String suffixStartSlaveCmd)
Deprecated. use the SSHUser based version

Constructor SSHLauncher creates a new SSHLauncher instance.

Parameters:
host - The host to connect to.
port - The port to connect on.
username - The username to connect as.
password - The password to connect with.
privatekey - The ssh privatekey to connect with.
jvmOptions - Options passed to the java vm.
javaPath - Path to the host jdk installation. If null the jdk will be auto detected or installed by the JDKInstaller.
prefixStartSlaveCmd - This will prefix the start slave command. For instance if you want to execute the command with a different shell.
suffixStartSlaveCmd - This will suffix the start slave command.

SSHLauncher

@Deprecated
public SSHLauncher(String host,
                              int port,
                              String username,
                              String password,
                              String privatekey,
                              String jvmOptions,
                              String javaPath,
                              hudson.tools.JDKInstaller jdkInstaller,
                              String prefixStartSlaveCmd,
                              String suffixStartSlaveCmd)
Deprecated. use the SSHUser based version

Constructor SSHLauncher creates a new SSHLauncher instance.

Parameters:
host - The host to connect to.
port - The port to connect on.
username - The username to connect as.
password - The password to connect with.
privatekey - The ssh privatekey to connect with.
jvmOptions - Options passed to the java vm.
javaPath - Path to the host jdk installation. If null the jdk will be auto detected or installed by the JDKInstaller.
jdkInstaller - The jdk installer that will be used if no java vm is found on the specified host. If null the SSHLauncher.DefaultJDKInstaller will be used.
prefixStartSlaveCmd - This will prefix the start slave command. For instance if you want to execute the command with a different shell.
suffixStartSlaveCmd - This will suffix the start slave command.

SSHLauncher

public SSHLauncher(String host,
                   int port,
                   com.cloudbees.jenkins.plugins.sshcredentials.SSHUser credentials,
                   String jvmOptions,
                   String javaPath,
                   hudson.tools.JDKInstaller jdkInstaller,
                   String prefixStartSlaveCmd,
                   String suffixStartSlaveCmd)
Constructor SSHLauncher creates a new SSHLauncher instance.

Parameters:
host - The host to connect to.
port - The port to connect on.
credentials - The credentials 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 or installed by the JDKInstaller.
jdkInstaller - The jdk installer that will be used if no java vm is found on the specified host. If null the SSHLauncher.DefaultJDKInstaller will be used.
prefixStartSlaveCmd - This will prefix the start slave command. For instance if you want to execute the command with a different shell.
suffixStartSlaveCmd - This will suffix the start slave command.

SSHLauncher

public SSHLauncher(String host,
                   int port,
                   String username,
                   String password,
                   String privatekey,
                   String jvmOptions)
Method Detail

lookupSystemCredentials

public static com.cloudbees.jenkins.plugins.sshcredentials.SSHUser lookupSystemCredentials(String credentialsId)

getCredentialsId

public String getCredentialsId()

getCredentials

public com.cloudbees.jenkins.plugins.sshcredentials.SSHUser getCredentials()

isLaunchSupported

public boolean isLaunchSupported()

Overrides:
isLaunchSupported in class hudson.slaves.ComputerLauncher

getJvmOptions

public String getJvmOptions()
Gets the JVM Options used to launch the slave JVM.

Returns:

getJavaPath

public String getJavaPath()
Gets the optionnal java command to use to launch the slave JVM.

Returns:

getTimestamp

protected String getTimestamp()
Gets the formatted current time stamp.

Returns:
the formatted current time stamp.

launch

public void launch(hudson.slaves.SlaveComputer computer,
                   hudson.model.TaskListener listener)
            throws InterruptedException

Overrides:
launch in class hudson.slaves.ComputerLauncher
Throws:
InterruptedException

resolveJava

protected String resolveJava(hudson.slaves.SlaveComputer computer,
                             hudson.model.TaskListener listener)
                      throws InterruptedException,
                             hudson.util.IOException2
return javaPath if specified in the configuration. Finds local Java, and if none exist, install one.

Throws:
InterruptedException
hudson.util.IOException2

reportEnvironment

protected void reportEnvironment(hudson.model.TaskListener listener)
                          throws IOException,
                                 InterruptedException
Throws:
IOException
InterruptedException

checkJavaVersion

protected String checkJavaVersion(PrintStream logger,
                                  String javaCommand,
                                  BufferedReader r,
                                  StringWriter output)
                           throws IOException
Given the output of "java -version" in r, determine if this version of Java is supported. This method has default visiblity for testing.

Parameters:
logger - where to log the output
javaCommand - the command executed, used for logging
r - the output of "java -version"
output - copy the data from r into this output buffer
Throws:
IOException

openConnection

protected void openConnection(hudson.model.TaskListener listener)
                       throws IOException,
                              InterruptedException
Throws:
IOException
InterruptedException

afterDisconnect

public void afterDisconnect(hudson.slaves.SlaveComputer slaveComputer,
                            hudson.model.TaskListener listener)

Overrides:
afterDisconnect in class hudson.slaves.ComputerLauncher

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'.

getUsername

@Deprecated
public String getUsername()
Deprecated. 

Getter for property 'username'.

Returns:
Value for property 'username'.

getPassword

@Deprecated
public String getPassword()
Deprecated. 

Getter for property 'password'.

Returns:
Value for property 'password'.

getPrivatekey

@Deprecated
public String getPrivatekey()
Deprecated. 

Getter for property 'privatekey'.

Returns:
Value for property 'privatekey'.

getConnection

public com.trilead.ssh2.Connection getConnection()

getPrefixStartSlaveCmd

public String getPrefixStartSlaveCmd()

getSuffixStartSlaveCmd

public String getSuffixStartSlaveCmd()


Copyright © 2004-2013. All Rights Reserved.