view autobot/template/master/master.cfg @ 250:48bc52d51252

make irc configurable
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 28 Dec 2011 11:07:38 -0800
parents 76b4f58df3ee
children 5db74374c122
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']:
    irc_host, nick = irc.split('@', 1):
    c['status'].append(words.IRC(host=irc_host, nick=nick
                                 channels=config.master['channels']))


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