view autobot/template/master/master.cfg @ 278:0f754bf9fd8a

maybe this is only one string...who knows?
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 31 Jul 2012 15:01:49 -0700
parents b19992f78f5c
children b2fd70c76dde
line wrap: on
line source

# -*- python -*-
# ex: set syntax=python:
c = BuildmasterConfig = {}

####### AUTOBOT CONFIG
import os
from autobot.config import BuildbotIniConfig
config = BuildbotIniConfig(os.path.join(basedir, 'master.ini'))

####### BUILDSLAVES
from buildbot.buildslave import BuildSlave
c['slaves'] = [BuildSlave(slave, config.slaves[slave]['password'])
               for slave in config.slaves]
c['slavePortnum'] = config.master['slaveport']

####### BUILDERS

# change sources
sources = {'git': set(),
           'hg':  set()}

builder_sources = {}

# define builder factories
from autobot.projects import factories as factory_dict
from autobot.projects import args
builders = []

for slave in config.slaves:
    for factory in config.slaves[slave]['factories']:

        # get the factory constructor arguments
        factory_args = config.args.get(factory, {}).copy()
        if 'platform' in args[factory]:
            # slave platform information
            factory_args['platform'] = config.slaves[slave]['platform']

        # make a factory
        f = factory_dict[factory](**factory_args)

        # define builder
        buildername = '%s - %s' % (factory, slave)
        b = {'name': buildername,
             'slavename': slave,
             'builddir': factory,
             'factory': f,
             }
        builders.append(b)

        # get change sources
        # XXX this should be moved to real code, not pseudo-config
        if not hasattr(f, 'sources'):
            continue
        for source_type in sources:
            _sources = f.sources.get(source_type, [])
            for source, branch in _sources:
                sources[source_type].add((source, branch))
                builder_sources.setdefault((source, branch), []).append(buildername)

c['builders'] = builders

####### CHANGESOURCES
from buildbot.changes.pb import PBChangeSource
c['change_source'] = [PBChangeSource()]

from autobot.changes.poller import GitPoller
from autobot.changes.poller import HgPoller

pollInterval = int(config.master.get('pollInterval', 60))

for repourl, branch in sources['git']:
    c['change_source'].append(GitPoller(
        repourl=repourl,
        pollInterval=pollInterval,
        branch=branch
        ))

for repourl, branch in sources['hg']:
    c['change_source'].append(HgPoller(
        repourl=repourl,
        pollInterval=pollInterval,
        branch=branch))


####### SCHEDULERS
from buildbot.scheduler import Scheduler
from buildbot.schedulers.filter import ChangeFilter
buildernames = [i['name'] for i in builders]
c['schedulers'] = []

treeStableTimer = int(config.master.get('treeStableTimer', 60))

for (source, branch), buildernames in builder_sources.items():
    change_filter = ChangeFilter(repository=source, branch=branch)
    c['schedulers'].append(Scheduler(name="%s#%s" % (source, branch),
                                     treeStableTimer=treeStableTimer,
                                     change_filter=change_filter,
                                     builderNames=buildernames))

####### STATUS TARGETS
c['status'] = []
from buildbot.status import html
from buildbot.status.web.authz import Authz

# force-build-enabled waterfall
authz = Authz(forceBuild=True, stopBuild=True)
c['status'].append(html.WebStatus(http_port=config.master['htmlport'],
                                  authz=authz))

# public waterfall
authz_public = Authz(forceBuild=False, stopBuild=False)
c['status'].append(html.WebStatus(http_port=config.master['publichtmlport'],
                                  authz=authz_public))

# irc bot
from buildbot.status import words
irc = config.master.get('irc', '')
if '@' in irc and config.master['channels']:
    nick, irc_host = irc.split('@', 1)
    if nick and irc_host:
        c['status'].append(words.IRC(host=irc_host, nick=nick,
                                     channels=config.master['channels']))

# email notification; see
# http://buildbot.net/buildbot/docs/latest/reference/buildbot.status.mail.MailNotifier-class.html
# http://buildbot.net/buildbot/docs/0.7.1/#Defining-Status-Targets
fromaddr = config.master.get('email', '')
recipients = config.master.get('recipients', None)
if recipients:
    recipients = recipients.split()
else:
    recipients = []
if fromaddr:
    from buildbot.status import mail
    m = mail.MailNotifier(fromaddr=fromaddr,
                          mode="problem",
                          extraRecipients=recipients,
                          sendToInterestedUsers=True)
    c['status'].append(m)

# autolog
#from autobot.status import autolog
#c['status'].append(autolog.AutologStatus())

####### PROJECT IDENTITY
c['projectName'] = "autobot"
c['projectURL'] = "http://buildbot.sourceforge.net/"
c['buildbotURL'] = "http://localhost:%d/" % config.master['htmlport']