Saturday 16 May 2015

Unexpected error in launching a slave. This is probably a bug in Jenkins

Launching a slave agent in Jenkins could result in the below error. This occurs when adding a Linux machine as slave node in Jenkins. Here ssh connection to the Linux server fails.

[05/17/15 00:53:52] [SSH] Opening SSH connection to 192.168.212.18:22.

Permission denied: connect
ERROR: Unexpected error in launching a slave. This is probably a bug in Jenkins.
java.lang.IllegalStateException: Connection is not established!
    at com.trilead.ssh2.Connection.getRemainingAuthMethods(Connection.java:1030)
    at com.cloudbees.jenkins.plugins.sshcredentials.impl.TrileadSSHPasswordAuthenticator.canAuthenticate(TrileadSSHPasswordAuthenticator.java:82)
    at com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator.newInstance(SSHAuthenticator.java:207)
    at com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator.newInstance(SSHAuthenticator.java:169)
    at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:1173)
    at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:701)
    at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:696)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
[05/17/15 00:53:53] Launch failed - cleaning up connection
[05/17/15 00:53:53] [SSH] Connection closed.




One instance where this could be corrected is to enable the publickey authentication in the linux server.

Few steps to do so are as below,


  • Edit the sshd_config file under /etc/ssh to modify the parameters, here we enable the publickey authentication and authorisedKeys.



  • After modifying the file to take effect restart sshd service



  • Then relaunch the slave agent which should be successful.












Creating slaves nodes of Linux and windows machines in Jenkins

Jenkins is a continuous integration tools for software development written in Java, where Builds can be started by  by commit in a version control system like git, svn  or by scheduling a time.
Builds can also be triggered after completing another build by having build dependencies by means of pre and post build actions.
Jenkins follows a master slave mechanism where no of slave nodes which are the actual clients where the builds are to be executed are added to the Jenkins masters. slave/masters can be running any operating system.
In this post we see how to add the Linux and windows nodes as slaves to the masters.
  1. From the Jenkins server navigate to the Manage Jenkins link on the left pane of the main page.
  2. which will take us to the control page of Jenkins where Manage Nodes link can be found.
  3. Now click the New Node link to create a new node
  4. Creating Linux node
  5. Enter the node name(Linux_Slave) and press OK
  6. Now click the configure link on the left pane as below and provide the configuration parameters as show in the screenshot.

  7. Here we provide the SSH login credentials to login to Linux machine and the path of JAVA_HOME has been given as a parameter.
  8. Save the node and verify the log console o the node.
  9.  Now the Slave node Linux_Slave is added to the jenkins master server. This node can be configure to use for any Jobs.

     
  10. Same process has to be followed to add a windows machine as slave to the Jenkins master.
  11.  The login method can be to use java web start as below
  12. Below picture shows the windows and Linux machine are added as slave nodes