How to automatically disconnect Jenkins Slave agent from Master controller server post build completion? - jenkins

We have a requirement to automatically disconnect Jenkins Slave agent from Master controller server once the build has been completed irrespective of its status. We are using windows agents in our case.
Anybody is having any idea, how to do that ?
Thanks in advance..!!

In the slave configuration page, there is a field calles "availability".
Check "Take this slave on-line when in demand and off-line when idle" and it should disconnect after running the job.

Related

Is it possible to trigger a job from Jenkins by parsing/receiving an event from Git/Gerrit Replica/Slave server?

I would like to connect my Jenkins to the Git/Gerrit replica/slave server. I want my Jenkins server to start building job once a commit is merged in the replica server. It is possible with Git/Gerrit Main server, but not sure whether this can be achieved via Gerrit replica or slave server.
I don't see any problem, I think you just need to create an additional Gerrit server at:
Jenkins > Manage Jenkins > Gerrit Trigger > Add New Server
And point to the replica/slave server at "Hostname" and "Frontend URL" fields.

Switch Jenkins Slave to a Different Master

I have a simple Jenkins master/slave set-up but I'd like to be able to switch which master the slave points at.
Is it possible to do this by changing some config on the slave?
For a Windows Slave configuration remove the JNLP Slave for Master1/Slave node by
1. Stopping the Jenkins Slave Windows service
2. Launch a Command Prompt as an Administrator
3. then use sc delete jenkins_service_name
For OS X check out https://github.com/rhwood/jenkins-slave-osx/wiki/Uninstall
Now open a browser on the slave machine and go to your Jenkins master2 server url then Jenkins -> Manage Jenkins -> Manage Nodes -> Node (assuming the node is already setup on master2 server) and click on the Launch button to launch agent from browser on slave machine. You prob. know how to do this already. If not use this guide https://wiki.jenkins-ci.org/display/JENKINS/Step+by+step+guide+to+set+up+master+and+slave+machines
Maybe you can try having the slave setup on both master1 and master2 by
1. Skip my delete steps above
2. open a browser on the slave machine and go to your Jenkins master2 server url then Jenkins -> Manage Jenkins -> Manage Nodes -> Node (assuming the node is already setup on master2 server) and click on the Launch button to launch agent from browser on slave machine.
3. Instead do "Save File" and click ok in step 5b from https://wiki.jenkins-ci.org/display/JENKINS/Step+by+step+guide+to+set+up+master+and+slave+machines
4. Save the slave-agent.jnlp to a new folder. I'm sure the two agents will run on that slave machine without interfering each other.
Definitely. If you want to be able to switch the slave back and forth between two masters, you can set up a second slave agent on the slave machine. Steps to do this depend on the type of slave (JNLP, remote ssh, etc). Disconnect the slave from the old master using the Manage Slaves page, and shut down the first slave agent on the slave machine. Start your second slave agent, and add that slave to the second master.
You can actually have both slave agents running and have the slave be connected to both masters, although they won't know anything about each other and could both send a job to the slave at the same time regardless of the number of executors.

Jenkins - How to build a master job in slave machine?

Initially, I configured the master and slave connection setup in windows machine by launching Java web start method. And then Created a Job in Master machine. Now my question is how to assign a master job to slave machine to build the job. Please provide me the steps to follows. Thanks you.
And please let me know is slave machine requires master machine URL for Connecting Master Slave Connection setup?
You can tie your job on whichever slave you want.
There is option of "Restrict where this project can be run", You can provide jenkins slave name on which this job should always run.
Answer to your last doubt. There is standard methods to connect slave to master, it depends how are you connecting the slave to master.

Jenkins build slave appears offline but slave service is up and Running

I am having trouble that Jenkins home page shows the Build slave is offline. But when I actually log in to build slave server, the slave service is up and running.
I am using Windows 2003 OS for all my Build slaves and Master server. The only way to get it online is to restart the service again.
Follow the given steps, you will not required to restart the services.
Goto Jenkins -> Manage Jenkins -> Manage Nodes
This will show you the list configured nodes.
In which
Build Slave -> Launch Slave Agent (Where "Build Slave" is your slave node.)
This will work if your slave is configured properly and connected with the services.
Jenkins master need communicate with Slave with ssh connection if master and slave are not in the same node.
Double check if master's ssh public key is in slave's ~/.ssh/authorized_keys.

How to configure Jenkins to send a notification email when a Slave goes offline?

How to configure Jenkins to send a notification email when a Slave goes offline?
I have a Windows Server in the Cloud.
In there is a Jenkins Slave running that runs a nightly build, but sometimes the Slave goes offline and I need to know when it goes offline.
How can I configure to Jenkins send me a email notification in this case?
The setting that Lars mentions does not seem to come with a default Jenkins installation (v1.514). I see it with the Mail watcher plugin
In the slave configuration, there's an option "Notify when Node online status changes". If you check it, it will allow you to enter email addresses to be notified when the slave comes online/goes offline.

Resources