Jenkins Fail Fast when Node is disabled

I have a MultiJob project (made with the Jenkins Multijob plugin), with several MultiJob phases. Let's say one of these jobs is called SubJob01. Each of the constructed tasks is configured with the option "Limit where this project can be launched", which should be tied to one node. SubJob01 is tied to Slave01.

I would like if these tasks did not succeed quickly when the node is disconnected, instead of saying "(pending-slave01 is offline)". In particular, I want there to be a record of an assembly attempt in SubJob01, while the assembly was flagged as unsuccessful. That way, I can set up my MultiJob project to handle the situation as I would like, instead of using the Jenkins build timeout plugin to abort it all.

Does anyone know how to quickly complete the assembly if all nodes are offline? I could cross the MultiJob project using Groovy system scripts to check if the needed nodes are offline, but it looks like it will be inventing in the wrong place, which should already be a function.

+7
jenkins groovy
source share
1 answer

I ended up creating this solution that worked well. The first step in building SubJob01 is the Execute Groovy script system, and this is the script:

import java.util.regex.Matcher import java.util.regex.Pattern int exitcode = 0 println("Looking for Offline Slaves:"); for (slave in hudson.model.Hudson.instance.slaves) { if (slave.getComputer().isOffline().toString() == "true"){ println(' * Slave ' + slave.name + " is offline!"); if (slave.name == "Slave01") { println(' !!!! This is Slave01 !!!!'); exitcode++; } // if slave.name } // if slave offline } // for slave in slaves println("\n\n"); println "Slave01 is offline: " + hudson.model.Hudson.instance.getNode("Slave01").getComputer().isOffline().toString(); println("\n\n"); if (exitcode > 0){ println("The Slave01 slave is offline - we can not possibly continue...."); println("Please contact IT to resolve the slave down issue before retrying the build."); return 1; } // if println("\n\n"); 
+1
source share

All Articles