Jenkins: how to test the slaves Jenkins: how to test the slaves jenkins jenkins

Jenkins: how to test the slaves


One option is to use Jenkins Groovy scripting for a task like this. The Groovy plugin provides the Jenkins Script Console (a useful way to experiment) and the ability to run groovy scripts as build steps. If you're going to use the Script Console for periodic maintenance, you'll also want the Scriptler plugin which allows you to manage the scripts that you run.

From Manage Jenkins -> Script Console, you can write a groovy script that iterates through the slaves and checks whether they are online:

for (node in Jenkins.instance.nodes) {  println "${node.name}, ${node.numExecutors}"  def computer = node.computer  println "Online: ${computer.online}, ${computer.connectTime} (${computer.offlineCauseReason})" }

Once you have the basic checks worked out, you can create either a standalone script in Scriptler, or a special build to run these checks periodically.

It often takes some iteration to figure out the right set of properties to examine. As I describe in another answer, you can write functions to introspect the objects available to scripting. And so with some trial and error, you can develop a script performs the checks you want to run.