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.
- Configure your Node and use "Launch agent via Java Web Start" launch method.
- 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.
- Now you need to connect your slave machine to the master using the following steps.
- 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.
- Go to Manage Jenkins > Manage Nodes, Click on the newly created slave machine.
- Click on the Launch button to launch agent from browser on slave.
- Now Save the jnlp file.
- 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.
- Click on Start -> All Programs -> Startup
- Right click on Startup and select “Open”
- C:\Users\<USER_NAME>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
- Right click on Right panel and select “Create Shortcut” option. (Available under “New” )
- 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
Post a Comment