Launch jenkins slave agent automatically on Windows reboot

 I was running Jenkins job on windows 7 and I was facing resources crunch. I needed to restart the Win-7 machine. Problem was to restart the Jenkins slave automatically when I reboot Win-7 machine.

There was problem setting up Jenkins slave as Windows service. I googled, found some documents and tried to set  registry as mentioned in those documents but did not get Jenkins agent running as service. Again, I dig Jenkins documents and found easy solution so sharing with you all.

  1. Configure your Node and use "Launch agent via Java Web Start" launch method.j1
  2. Download Jenkins Slave.jar file.  copy of slave.jar can be downloaded from http://yourserver:port/jnlpJars/slave.jar . Save it on your Node/Slave.
  3. Now you need to connect your slave machine to the master using the following steps.
    1. Open a browser on the slave machine and go to the Jenkins master server URL (http://yourjenkinsmaster:8080). OR you can access http://yourjenkinsmaster:8080/computer/<NodName_OR_NodeIP>/ directly and avoid step # 2.
    2. Go to Manage Jenkins > Manage Nodes, Click on the newly created slave machine.
    3. Click on the Launch button to launch agent from browser on slave.j2
    4. Now Save the jnlp file.
  4. Now go to the folder where you saved slave.jar file and run following command.

java -jar <folder>/slave.jar -jnlpUrl http://yourjenkinsmaster:8080/computer/<yourNodeIP_OR_YourNodeName>/slave-agent.jnlp

5. Go to Jenkins master and refresh the home page. Your slave is connected to the Jenkins master. Hurrah!!!!

6. Put this command in Batch file and create a shortcut in Startup folder so that when you restart your Windows machine, Jenkins Agent on slave will be started automatically.

  1. Click on Start -> All Programs -> Startup
  2. Right click on Startup and select “Open”
    1. C:\Users\<USER_NAME>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
  3. Right click on Right panel and select “Create Shortcut” option. (Available under “New” )
  4. Browse the location where you created *.bat and select it. Click OK->Next and Finish it.

7. Reboot your machine and verify  on master machine when your machine is up.

Isn't it easy ?

Comments

Popular posts from this blog

Selenium: File download handling.

Major Differences between Python and Java

Cypress V/S Selenium