While looking around for automated build systems years ago, I stopped at buildbot - http://buildbot.net/

Buildbot never stopped surprizing me in the good way.

Probably one of the best usage is at Chromium Project - http://build.chromium.org/p/chromium/waterfall

While I try to design and implement Continuous Integration pilot on Clearcase/UCM repository, many challenges are on-going and with buildbot one can handle them quite easy.

The software is open source, still it was not trivial to find example of some “advanced” usage.

Below is the nextSlave function I'm using, that hopefully will choose the slave with lowest number of running builds that can acquire the configured slave locks:

def getNbOfActiveBuilders(slaveBuilders):
   active_builders = [sb for sb in slaveBuilders.slave.slavebuilders.values()
                      if sb.isBusy()]

   return len(active_builders)
   

def myNextBuildSlave(builder, slaveBuilders):
   slaveBuilders.sort(key=lambda s: getNbOfActiveBuilders(s))
   for sb in slaveBuilders:
      if builder.canStartWithSlavebuilder(sb): #check locks before
         return sb
   return None