One way to accomplish this is by adding a new scheduler called DependentNightly, this scheduler receives a new parameter called relatedBuilderNames containing a set of builders that the scheduler should watch. The startbuild method will now check, for every related builder, the last finished build status and start the knightly build if no failures are found. Bellow master.cfg changes.
from buildbot.schedulers.basic import SingleBranchScheduler from buildbot.schedulers.timed import Nightly from buildbot.changes import filter from buildbot.status.builder import SUCCESS, WARNINGS, FAILURE from twisted.python import log from twisted.internet import defer class DependentNightly(Nightly): relatedBuilderNames = [] def __init__(self, relatedBuilderNames = [], **kwargs): Nightly.__init__(self, **kwargs) self.relatedBuilderNames = relatedBuilderNames def startBuild(self): startBuild = True for builderName in self.relatedBuilderNames: builder_status = self.master.status.getBuilder(builderName) lastBuild = builder_status.getLastFinishedBuild() if lastBuild != None: startBuild = startBuild and (lastBuild.getResults() != FAILURE) if (startBuild): return Nightly.startBuild(self) else: log.msg(("Nightly Scheduler <%s>: skipping build. " + "- Related builder <%s> failed last build") % (self.name, ", ".join(self.relatedBuilderNames))) return defer.succeed(None) c['schedulers'] = [] c['schedulers'].append(SingleBranchScheduler( name="Continuous", change_filter=filter.ChangeFilter(branch='master'), treeStableTimer=3*60, builderNames=["Continuous"])) c['schedulers'].append(DependentNightly( name="Ninghtly", branch='master', hour=13, minute=24, onlyIfChanged=False, builderNames=["Ninghtly"], relatedBuilderNames=["Continuous"] ))
When the scheduler finds out that the build won’t run, a message will be log to twistd.log file as shown bellow.
I hope this series of blog posts were helpful to give you an overall idea about using buildbot for CI.
No comments:
Post a Comment