Package buildbot :: Package process :: Module builder :: Class Builder
[frames] | no frames]

Class Builder

source code

  twisted.spread.jelly.Jellyable --+        
                                   |        
 twisted.spread.flavors.Serializable --+    
                                       |    
    twisted.spread.flavors.Referenceable --+
                                           |
 twisted.application.service.Service --+   |
                                       |   |
twisted.application.service.MultiService --+
                                           |
                                          Builder

I manage all Builds of a given type.

Each Builder is created by an entry in the config file (the c['builders'] list), with a number of parameters.

One of these parameters is the buildbot.process.factory.BuildFactory object that is associated with this Builder. The factory is responsible for creating new Build objects. Each Build object defines when and how the build is performed, so a new Factory or Builder should be defined to control this behavior.

The Builder holds on to a number of base.BuildRequest objects in a list named .buildable. Incoming BuildRequest objects will be added to this list, or (if possible) merged into an existing request. When a slave becomes available, I will use my BuildFactory to turn the request into a new Build object. The BuildRequest is forgotten, the Build goes into .building while it runs. Once the build finishes, I will discard it.

I maintain a list of available SlaveBuilders, one for each connected slave that the slavenames parameter says we can use. Some of these will be idle, some of them will be busy running builds for me. If there are multiple slaves, I can run multiple builds at once.

I also manage forced builds, progress expectation (ETA) management, and some status delivery chores.

Instance Methods
 
__init__(self, setup, builder_status) source code
 
setBotmaster(self, botmaster) source code
 
compareToSetup(self, setup) source code
 
__repr__(self) source code
 
triggerNewBuildCheck(self) source code
 
run(self)
Check for work to be done.
source code
 
getBuildable(self) source code
 
getOldestRequestTime(self)
Returns the timestamp of the oldest build request for this builder.
source code
 
cancelBuildRequest(self, brid) source code
 
consumeTheSoulOfYourPredecessor(self, old)
Suck the brain out of an old Builder.
source code
 
reclaimAllBuilds(self) source code
 
getBuild(self, number) source code
 
fireTestEvent(self, name, fire_with=None) source code
 
addLatentSlave(self, slave) source code
twisted.internet.defer.Deferred
attached(self, slave, remote, commands)
This is invoked by the BuildSlave when the self.slavename bot registers their builder.
source code
 
detached(self, slave)
This is called when the connection to the bot is lost.
source code
 
updateBigStatus(self) source code
 
startBuild(self, build, sb)
Start a build on the given slave.
source code
 
setupProperties(self, props) source code
 
buildFinished(self, build, sb, bids)
This is called when the Build has finished (either success or failure).
source code
 
setExpectations(self, progress)
Mark the build as successful and update expectations for the next build.
source code
 
shutdownSlave(self) source code

Inherited from twisted.spread.flavors.Referenceable: jellyFor, remoteMessageReceived

Inherited from twisted.spread.flavors.Serializable: processUniqueID

Inherited from twisted.spread.jelly.Jellyable: __providedBy__, getStateFor

Inherited from twisted.application.service.MultiService: __iter__, addService, getServiceNamed, privilegedStartService, removeService, startService, stopService

Inherited from twisted.application.service.Service: __getstate__, disownServiceParent, setName, setServiceParent

Class Variables
  expectations = None
  CHOOSE_SLAVES_RANDOMLY = True
  RECLAIM_INTERVAL = 3600

Inherited from twisted.spread.flavors.Referenceable: __implemented__, __provides__, perspective

Inherited from twisted.application.service.Service: name, parent, running

Instance Variables
list of buildbot.process.base.BuildRequest buildable
BuildRequests that are ready to build, but which are waiting for a buildslave to be available.
list of buildbot.process.base.Build building
Builds that are actively running
list of buildbot.buildslave.BuildSlave objects slaves
the slaves currently available for building
Method Details

__init__(self, setup, builder_status)
(Constructor)

source code 
Parameters:
  • setup (dict) - builder setup data, as stored in BuildmasterConfig['builders']. Contains name, slavename(s), builddir, slavebuilddir, factory, locks.
  • builder_status (buildbot.status.builder.BuilderStatus)
Overrides: twisted.application.service.MultiService.__init__

run(self)

source code 

Check for work to be done. This should be called any time I might be able to start a job:

  • when the Builder is first created
  • when a new job has been added to the [buildrequests] DB table
  • when a slave has connected

If I have both an available slave and the database contains a BuildRequest that I can handle, I will claim the BuildRequest and start the build. When the build finishes, I will retire the BuildRequest.

getOldestRequestTime(self)

source code 

Returns the timestamp of the oldest build request for this builder.

If there are no build requests, None is returned.

consumeTheSoulOfYourPredecessor(self, old)

source code 

Suck the brain out of an old Builder.

This takes all the runtime state from an existing Builder and moves it into ourselves. This is used when a Builder is changed in the master.cfg file: the new Builder has a different factory, but we want all the builds that were queued for the old one to get processed by the new one. Any builds which are already running will keep running. The new Builder will get as many of the old SlaveBuilder objects as it wants.

attached(self, slave, remote, commands)

source code 

This is invoked by the BuildSlave when the self.slavename bot registers their builder.

Parameters:
Returns: twisted.internet.defer.Deferred
a Deferred that fires (with 'self') when the slave-side builder is fully attached and ready to accept commands.

startBuild(self, build, sb)

source code 

Start a build on the given slave.

Parameters:
Returns:
a Deferred which fires with a buildbot.interfaces.IBuildControl that can be used to stop the Build, or to access a buildbot.interfaces.IBuildStatus which will watch the Build as it runs.

buildFinished(self, build, sb, bids)

source code 

This is called when the Build has finished (either success or failure). Any exceptions during the build are reported with results=FAILURE, not with an errback.

setExpectations(self, progress)

source code 

Mark the build as successful and update expectations for the next build. Only call this when the build did not fail in any way that would invalidate the time expectations generated by it. (if the compile failed and thus terminated early, we can't use the last build to predict how long the next one will take).