view autobot/template/master/master.cfg @ 302:8bc0160993a2

remove reference to autolog
author Jeff Hammel <k0scist@gmail.com>
date Sun, 11 May 2014 09:53:00 -0700
parents 3a4b11d4fdf0
children
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
from buildbot.schedulers.forcesched import *
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)
    name = "%s#%s" % (source, branch)
    c['schedulers'].append(Scheduler(name=name,
                                     treeStableTimer=treeStableTimer,
                                     change_filter=change_filter,
                                     builderNames=buildernames))

    # add a force scheduler
    # see http://buildbot.net/buildbot/docs/0.8.6/manual/cfg-schedulers.html#forcescheduler-scheduler
    sch = ForceScheduler(name="force-%s" % name,
                         builderNames=buildernames,
                         branch=FixedParameter(name="branch", default=branch),

                         # will generate a text input
                         reason=StringParameter(name="reason",label="reason:",
                                                required=False, size=80),

                         # will generate nothing in the form, but revision, repository,
                         # and project are needed by buildbot scheduling system so we
                         # need to pass a value ("")
                         revision=FixedParameter(name="revision", default=""),
                         repository=FixedParameter(name="repository", default=""),
                         project=FixedParameter(name="repository", default=""),

                         # in case you dont require authentication this will display
                         # input for user to type his name
                         username=UserNameParameter(label="your name:", size=80))
    c['schedulers'].append(sch)

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

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

# public waterfall
publichtmlport = config.master.get('publichtmlport')
if publichtmlport:
    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, allowForce=False,
                                     events={'failure': 1,
                                             'exception': 1,
                                             },
                                     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', 'autobot@{{domain}}')
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)


####### PROJECT IDENTITY
c['projectName'] = "autobot"
c['projectURL'] = "http://buildbot.sourceforge.net/"
c['buildbotURL'] = "http://{{domain}}:%s/" % config.master.get('publichtmlport', 80)