Showing posts with label jenkins. Show all posts
Showing posts with label jenkins. Show all posts

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

Tuesday, 24 March 2015

Running testng class file from cmd prompt and jenkins

we can run the testng class files through eclipse by adding the testng libraries in Build path.
If we need to run the same testng class files from command prompt and through any tools we could do so by adding the testng libraries to the CLASSPATH variable. or by giving the path with -cp option available in java. Also can add any jar files which are referred in the class files.



set CLASSPATH = %CLASSPATH%;D:\Are\Sel\Ecom_project\TestNG\testng-6.8.jar

D:\Area\Sel\>java org.testng.TestNG testng.xml
[TestNG] Running:
  D:\Are\Sel\Ecom_project\src\scripts\testng.xml

TestNG is working fine
===============================================
Suite1
Total tests run: 1, Failures: 0, Skips: 0
===============================================



To run the same testng scripts via Jenkins can add the CLASSPATH variable at master level or at node level specifying the path of the jar files. Represented the same in below snaps.










 

Wednesday, 9 April 2014

Installing Jenkins in Unix/windows machine

1. Download jenkins.war file from http://jenkins-ci.org/ and upload it to the server

2. Execute the java web archive (Jenkins.war file) by running command

java –jar jenkins.war


3. The Jenkins server page can be viewed in browser on http://<server_ip>:<port_no>/



     After the server page is loaded


4. Now the Jenkins server is up and running. The new jobs and new nodes on which the jobs are designed to run should be set up.

Saturday, 22 March 2014

Exception in thread "main" java.lang.AssertionError: Subclass must override this method


Exception in thread "main" java.lang.AssertionError: Subclass must override this method

   at java.lang.reflect.AccessibleObject.getAnnotation(libgcj.so.7rh)

   at org.kohsuke.args4j.ClassParser.parse(ClassParser.java:21)
   at org.kohsuke.args4j.CmdLineParser.<init>(CmdLineParser.java:91)
   at hudson.remoting.Launcher.main(Launcher.java:170)
To overcome this on launching slave.jar as part of jekins setup, try using latest java version.
This should be solved on using the latest java versions.