Пример #1
0
        def setup(_):
            # set up a fake service hierarchy
            self.master = mock.Mock()
            self.master.slavePortnum = '9999'
            self.master.pbmanager = self.pbmanager
            self.master.change_svc = self.changemaster
            self.master.change_svc.parent = self.master

            # and a change source
            self.change_source = PBChangeSource('alice', 'sekrit')
            self.change_source.parent = self.master.change_svc
Пример #2
0
def change_source(name, password):
    """
    Adds a new change source. This causes BuildBot to start listening on TCP port 9999. Make sure
    to have it behind a firewall and open only to addresses from which you want to listen for
    change notifications.

    """
    BuildmasterConfig['change_source'].append(
        PBChangeSource(port=9999, user=name, passwd=password))
Пример #3
0
class TestPBChangeSource(
            changesource.ChangeSourceMixin,
            pbmanager.PBManagerMixin,
            TestCase):

    def setUp(self):
        self.setUpPBChangeSource()
        d = self.setUpChangeSource()

        def setup(_):
            # set up a fake service hierarchy
            self.master = mock.Mock()
            self.master.slavePortnum = '9999'
            self.master.pbmanager = self.pbmanager
            self.master.change_svc = self.changemaster
            self.master.change_svc.parent = self.master

            # and a change source
            self.change_source = PBChangeSource('alice', 'sekrit')
            self.change_source.parent = self.master.change_svc
        d.addCallback(setup)

        return d

    def test_describe(self):
        self.assertIn("PBChangeSource", self.change_source.describe())

    def test_registration(self):
        self.change_source.startService()
        self.assertRegistered('9999', 'alice', 'sekrit')
        d = self.change_source.stopService()
        def check(_):
            self.assertUnregistered('9999', 'alice', 'sekrit')
        d.addCallback(check)
        return d

    def test_perspective(self):
        persp = self.change_source.getPerspective(mock.Mock(), 'alice')
        self.assertIsInstance(persp, ChangePerspective)
        persp.perspective_addChange(dict(who='me', files=['a'], comments='comm'))
        self.assertEqual(len(self.changes_added), 1)
Пример #4
0
# will help to flush out any bugs that may otherwise be difficult to find.

c = BuildmasterConfig = {}
from buildbot.changes.filter import ChangeFilter
from buildbot.changes.pb import PBChangeSource
from buildbot.config import BuilderConfig
from buildbot.process.factory import BuildFactory
from buildbot.schedulers.basic import AnyBranchScheduler
from buildbot.schedulers.forcesched import ForceScheduler
from buildbot.steps.shell import ShellCommand
from buildbot.worker import Worker

c['workers'] = [Worker("local1", "localpw")]
c['protocols'] = {'pb': {'port': 'tcp:0'}}
c['change_source'] = []
c['change_source'] = PBChangeSource()
c['schedulers'] = []
c['schedulers'].append(
    AnyBranchScheduler(name="all",
                       change_filter=ChangeFilter(project_re='^testy/'),
                       treeStableTimer=1 * 60,
                       builderNames=[
                           'testy',
                       ]))
c['schedulers'].append(ForceScheduler(name="force", builderNames=["testy"]))
f1 = BuildFactory()
f1.addStep(ShellCommand(command='echo hi'))
c['builders'] = []
c['builders'].append(
    BuilderConfig(name="testy", workernames=["local1"], factory=f1))
c['status'] = []
Пример #5
0
            def loadConfig(self, f):
                # modified from parent method to get slaves, projects, change
                # sources, schedulers, builders and web status ouf of
                # master.cfg [it would have been cleaner if jhbuild didn't
                # have to copy all that code.]
                localDict = {'basedir': os.path.expanduser(self.basedir)}
                try:
                    exec f in localDict
                except:
                    log.msg("error while parsing config file")
                    raise

                jhbuild_config.load()

                try:
                    config = localDict['BuildmasterConfig']
                except KeyError:
                    log.err("missing config dictionary")
                    log.err("config file must define BuildmasterConfig")
                    raise

                known_keys = ("bots", "slaves",
                              "sources", "change_source",
                              "schedulers", "builders", "mergeRequests",
                              "slavePortnum", "debugPassword", "logCompressionLimit",
                              "manhole", "status", "projectName", "projectURL",
                              "buildbotURL", "properties", "prioritizeBuilders",
                              "eventHorizon", "buildCacheSize", "logHorizon", "buildHorizon",
                              "changeHorizon", "logMaxSize", "logMaxTailSize",
                              "logCompressionMethod",
                              )
                for k in config.keys():
                    if k not in known_keys:
                        log.msg("unknown key '%s' defined in config dictionary" % k)

                # the 'slaves' list is read from the 'slaves.csv' file in the
                # current directory (unless instructed different from command line) 
                # it is a CSV file structured like this:
                #   slavename,password
                config['slaves'] = []
                slaves_csv_file = os.path.join(slaves_dir, 'slaves.csv')
                if os.path.exists(slaves_csv_file):
                    for x in csv.reader(file(slaves_csv_file)):
                        if not x or x[0].startswith('#'):
                            continue
                        kw = {}
                        build_slave = JhBuildSlave(x[0], x[1])
                        build_slave.load_extra_configuration(slaves_dir)
                        config['slaves'].append(build_slave)

                if len(config['slaves']) == 0:
                    log.msg('you must fill slaves.csv with slaves')

                module_set = jhbuild.moduleset.load(self.jhbuild_config)
                module_list = module_set.get_module_list(
                        self.jhbuild_config.modules,
                        self.jhbuild_config.skip,
                        include_optional_modules=True)
                config['projects'] = [x.name for x in module_list \
                                      if not x.name.startswith('meta-')]

                if self.jhbuild_config.jhbuildbot_svn_commits_box:
                    # trigger builds from mails to svn-commit-list
                    # (note Maildir must be correct, or everything will fail)
                    from jhbuild.buildbot.changes import GnomeMaildirSource
                    config['change_source'] = GnomeMaildirSource(
                            self.jhbuild_config.jhbuildbot_svn_commits_box,
                            modules=module_list,
                            prefix=None)
                else:
                    # support injection (use 'buildbot sendchange')
                    from buildbot.changes.pb import PBChangeSource
                    config['change_source'] = PBChangeSource()

                # Schedulers
                from jhbuild.buildbot.scheduler import SerialScheduler, NightlySerialScheduler, OnCommitScheduler
                config['schedulers'] = []
                for slave in config['slaves']:
                    s = None
                    for project in config['projects']:
                        buildername = str('%s-%s' % (project, slave.slavename))
                        scheduler_kwargs = {}
                        if slave.scheduler == 'nightly':
                            scheduler_class = NightlySerialScheduler
                            scheduler_kwargs = slave.nightly_kwargs
                        else:
                            scheduler_class = SerialScheduler
                        s = scheduler_class(buildername, project, upstream=s,
                                            builderNames=[buildername],
                                            **scheduler_kwargs)
                        config['schedulers'].append(s)
                        if self.jhbuild_config.jhbuildbot_svn_commits_box:
                            # schedulers that will launch job when receiving
                            # change notifications
                            s2 = OnCommitScheduler('oc-' + buildername,
                                    project, builderNames=[buildername])
                            config['schedulers'].append(s2)

                # Builders
                from jhbuild.buildbot.factory import JHBuildFactory
                config['builders'] = []
                for project in config['projects']:
                    for slave in config['slaves']:
                        f = JHBuildFactory(project, slave)
                        config['builders'].append({
                            'name' : "%s-%s" % (project, slave.slavename),
                            'slavename' : slave.slavename,
                            'builddir' : 'builddir/%s.%s' % (project, slave.slavename),
                            'factory' : f,
                            'category' : project
                        })

                # Status targets
                if not config.has_key('status'):
                    # let it be possible to define additional status in
                    # master.cfg
                    config['status'] = []

                from jhbuild.buildbot.status.web import JHBuildWebStatus
                config['status'].append(
                    JHBuildWebStatus(
                        self.jhbuild_config.moduleset,
                        config['projects'],
                        [x.slavename for x in config['slaves']],
                        http_port=8080, allowForce=True)
                )

                # remaining of the method is a straight copy from buildbot
                # ...
                try:
                    # required
                    schedulers = config['schedulers']
                    builders = config['builders']
                    slavePortnum = config['slavePortnum']
                    #slaves = config['slaves']
                    #change_source = config['change_source']

                    # optional
                    debugPassword = config.get('debugPassword')
                    manhole = config.get('manhole')
                    status = config.get('status', [])
                    projectName = config.get('projectName')
                    projectURL = config.get('projectURL')
                    buildbotURL = config.get('buildbotURL')
                    properties = config.get('properties', {})
                    buildCacheSize = config.get('buildCacheSize', None)
                    eventHorizon = config.get('eventHorizon', None)
                    logHorizon = config.get('logHorizon', None)
                    buildHorizon = config.get('buildHorizon', None)
                    logCompressionLimit = config.get('logCompressionLimit', 4*1024)
                    if logCompressionLimit is not None and not \
                            isinstance(logCompressionLimit, int):
                        raise ValueError("logCompressionLimit needs to be bool or int")
                    logCompressionMethod = config.get('logCompressionMethod', "bz2")
                    if logCompressionMethod not in ('bz2', 'gz'):
                        raise ValueError("logCompressionMethod needs to be 'bz2', or 'gz'")
                    logMaxSize = config.get('logMaxSize')
                    if logMaxSize is not None and not \
                            isinstance(logMaxSize, int):
                        raise ValueError("logMaxSize needs to be None or int")
                    logMaxTailSize = config.get('logMaxTailSize')
                    if logMaxTailSize is not None and not \
                            isinstance(logMaxTailSize, int):
                        raise ValueError("logMaxTailSize needs to be None or int")
                    mergeRequests = config.get('mergeRequests')
                    if mergeRequests is not None and not callable(mergeRequests):
                        raise ValueError("mergeRequests must be a callable")
                    prioritizeBuilders = config.get('prioritizeBuilders')
                    if prioritizeBuilders is not None and not callable(prioritizeBuilders):
                        raise ValueError("prioritizeBuilders must be callable")
                    changeHorizon = config.get("changeHorizon")
                    if changeHorizon is not None and not isinstance(changeHorizon, int):
                        raise ValueError("changeHorizon needs to be an int")

                except KeyError, e:
                    log.msg("config dictionary is missing a required parameter")
                    log.msg("leaving old configuration in place")
                    raise
 def __init__(self, comparator, *args, **kwargs):
     self.comparator = comparator
     PBChangeSource.__init__(self, *args, **kwargs)
Пример #7
0
            def loadConfig(self, f):
                # modified from parent method to get slaves, projects, change
                # sources, schedulers, builders and web status ouf of
                # master.cfg [it would have been cleaner if jhbuild didn't
                # have to copy all that code.]
                localDict = {'basedir': os.path.expanduser(self.basedir)}
                try:
                    exec f in localDict
                except:
                    log.msg("error while parsing config file")
                    raise

                jhbuild_config.load()

                try:
                    config = localDict['BuildmasterConfig']
                except KeyError:
                    log.err("missing config dictionary")
                    log.err("config file must define BuildmasterConfig")
                    raise

                known_keys = (
                    "bots",
                    "slaves",
                    "sources",
                    "change_source",
                    "schedulers",
                    "builders",
                    "mergeRequests",
                    "slavePortnum",
                    "debugPassword",
                    "logCompressionLimit",
                    "manhole",
                    "status",
                    "projectName",
                    "projectURL",
                    "buildbotURL",
                    "properties",
                    "prioritizeBuilders",
                    "eventHorizon",
                    "buildCacheSize",
                    "logHorizon",
                    "buildHorizon",
                    "changeHorizon",
                    "logMaxSize",
                    "logMaxTailSize",
                    "logCompressionMethod",
                )
                for k in config.keys():
                    if k not in known_keys:
                        log.msg(
                            "unknown key '%s' defined in config dictionary" %
                            k)

                # the 'slaves' list is read from the 'slaves.csv' file in the
                # current directory (unless instructed different from command line)
                # it is a CSV file structured like this:
                #   slavename,password
                config['slaves'] = []
                slaves_csv_file = os.path.join(slaves_dir, 'slaves.csv')
                if os.path.exists(slaves_csv_file):
                    for x in csv.reader(file(slaves_csv_file)):
                        if not x or x[0].startswith('#'):
                            continue
                        kw = {}
                        build_slave = JhBuildSlave(x[0], x[1])
                        build_slave.load_extra_configuration(slaves_dir)
                        config['slaves'].append(build_slave)

                if len(config['slaves']) == 0:
                    log.msg('you must fill slaves.csv with slaves')

                module_set = jhbuild.moduleset.load(self.jhbuild_config)
                module_list = module_set.get_module_list(
                    self.jhbuild_config.modules,
                    self.jhbuild_config.skip,
                    include_afters=True)
                config['projects'] = [x.name for x in module_list \
                                      if not x.name.startswith('meta-')]

                if self.jhbuild_config.jhbuildbot_svn_commits_box:
                    # trigger builds from mails to svn-commit-list
                    # (note Maildir must be correct, or everything will fail)
                    from jhbuild.buildbot.changes import GnomeMaildirSource
                    config['change_source'] = GnomeMaildirSource(
                        self.jhbuild_config.jhbuildbot_svn_commits_box,
                        modules=module_list,
                        prefix=None)
                else:
                    # support injection (use 'buildbot sendchange')
                    from buildbot.changes.pb import PBChangeSource
                    config['change_source'] = PBChangeSource()

                # Schedulers
                from jhbuild.buildbot.scheduler import SerialScheduler, NightlySerialScheduler, OnCommitScheduler
                config['schedulers'] = []
                for slave in config['slaves']:
                    s = None
                    for project in config['projects']:
                        buildername = str('%s-%s' % (project, slave.slavename))
                        scheduler_kwargs = {}
                        if slave.scheduler == 'nightly':
                            scheduler_class = NightlySerialScheduler
                            scheduler_kwargs = slave.nightly_kwargs
                        else:
                            scheduler_class = SerialScheduler
                        s = scheduler_class(buildername,
                                            project,
                                            upstream=s,
                                            builderNames=[buildername],
                                            **scheduler_kwargs)
                        config['schedulers'].append(s)
                        if self.jhbuild_config.jhbuildbot_svn_commits_box:
                            # schedulers that will launch job when receiving
                            # change notifications
                            s2 = OnCommitScheduler('oc-' + buildername,
                                                   project,
                                                   builderNames=[buildername])
                            config['schedulers'].append(s2)

                # Builders
                from jhbuild.buildbot.factory import JHBuildFactory
                config['builders'] = []
                for project in config['projects']:
                    for slave in config['slaves']:
                        f = JHBuildFactory(project, slave)
                        config['builders'].append({
                            'name':
                            "%s-%s" % (project, slave.slavename),
                            'slavename':
                            slave.slavename,
                            'builddir':
                            'builddir/%s.%s' % (project, slave.slavename),
                            'factory':
                            f,
                            'category':
                            project
                        })

                # Status targets
                if not config.has_key('status'):
                    # let it be possible to define additional status in
                    # master.cfg
                    config['status'] = []

                from jhbuild.buildbot.status.web import JHBuildWebStatus
                config['status'].append(
                    JHBuildWebStatus(self.jhbuild_config.moduleset,
                                     config['projects'],
                                     [x.slavename for x in config['slaves']],
                                     http_port=8080,
                                     allowForce=True))

                # remaining of the method is a straight copy from buildbot
                # ...
                try:
                    # required
                    schedulers = config['schedulers']
                    builders = config['builders']
                    slavePortnum = config['slavePortnum']
                    #slaves = config['slaves']
                    #change_source = config['change_source']

                    # optional
                    debugPassword = config.get('debugPassword')
                    manhole = config.get('manhole')
                    status = config.get('status', [])
                    projectName = config.get('projectName')
                    projectURL = config.get('projectURL')
                    buildbotURL = config.get('buildbotURL')
                    properties = config.get('properties', {})
                    buildCacheSize = config.get('buildCacheSize', None)
                    eventHorizon = config.get('eventHorizon', None)
                    logHorizon = config.get('logHorizon', None)
                    buildHorizon = config.get('buildHorizon', None)
                    logCompressionLimit = config.get('logCompressionLimit',
                                                     4 * 1024)
                    if logCompressionLimit is not None and not \
                            isinstance(logCompressionLimit, int):
                        raise ValueError(
                            "logCompressionLimit needs to be bool or int")
                    logCompressionMethod = config.get('logCompressionMethod',
                                                      "bz2")
                    if logCompressionMethod not in ('bz2', 'gz'):
                        raise ValueError(
                            "logCompressionMethod needs to be 'bz2', or 'gz'")
                    logMaxSize = config.get('logMaxSize')
                    if logMaxSize is not None and not \
                            isinstance(logMaxSize, int):
                        raise ValueError("logMaxSize needs to be None or int")
                    logMaxTailSize = config.get('logMaxTailSize')
                    if logMaxTailSize is not None and not \
                            isinstance(logMaxTailSize, int):
                        raise ValueError(
                            "logMaxTailSize needs to be None or int")
                    mergeRequests = config.get('mergeRequests')
                    if mergeRequests is not None and not callable(
                            mergeRequests):
                        raise ValueError("mergeRequests must be a callable")
                    prioritizeBuilders = config.get('prioritizeBuilders')
                    if prioritizeBuilders is not None and not callable(
                            prioritizeBuilders):
                        raise ValueError("prioritizeBuilders must be callable")
                    changeHorizon = config.get("changeHorizon")
                    if changeHorizon is not None and not isinstance(
                            changeHorizon, int):
                        raise ValueError("changeHorizon needs to be an int")

                except KeyError as e:
                    log.msg(
                        "config dictionary is missing a required parameter")
                    log.msg("leaving old configuration in place")
                    raise

                #if "bots" in config:
                #    raise KeyError("c['bots'] is no longer accepted")

                slaves = config.get('slaves', [])
                if "bots" in config:
                    m = ("c['bots'] is deprecated as of 0.7.6 and will be "
                         "removed by 0.8.0 . Please use c['slaves'] instead.")
                    log.msg(m)
                    warnings.warn(m, DeprecationWarning)
                    for name, passwd in config['bots']:
                        slaves.append(JhBuildSlave(name, passwd))

                if "bots" not in config and "slaves" not in config:
                    log.msg(
                        "config dictionary must have either 'bots' or 'slaves'"
                    )
                    log.msg("leaving old configuration in place")
                    raise KeyError("must have either 'bots' or 'slaves'")

                #if "sources" in config:
                #    raise KeyError("c['sources'] is no longer accepted")

                if changeHorizon is not None:
                    self.change_svc.changeHorizon = changeHorizon

                change_source = config.get('change_source', [])
                if isinstance(change_source, (list, tuple)):
                    change_sources = change_source
                else:
                    change_sources = [change_source]
                if "sources" in config:
                    m = (
                        "c['sources'] is deprecated as of 0.7.6 and will be "
                        "removed by 0.8.0 . Please use c['change_source'] instead."
                    )
                    log.msg(m)
                    warnings.warn(m, DeprecationWarning)
                    for s in config['sources']:
                        change_sources.append(s)

                # do some validation first
                for s in slaves:
                    assert interfaces.IBuildSlave.providedBy(s)
                    if s.slavename in ("debug", "change", "status"):
                        raise KeyError("reserved name '%s' used for a bot" %
                                       s.slavename)
                if config.has_key('interlocks'):
                    raise KeyError("c['interlocks'] is no longer accepted")

                assert isinstance(change_sources, (list, tuple))
                for s in change_sources:
                    assert interfaces.IChangeSource(s, None)
                # this assertion catches c['schedulers'] = Scheduler(), since
                # Schedulers are service.MultiServices and thus iterable.
                errmsg = "c['schedulers'] must be a list of Scheduler instances"
                assert isinstance(schedulers, (list, tuple)), errmsg
                for s in schedulers:
                    assert interfaces.IScheduler(s, None), errmsg
                assert isinstance(status, (list, tuple))
                for s in status:
                    assert interfaces.IStatusReceiver(s, None)

                slavenames = [s.slavename for s in slaves]
                buildernames = []
                dirnames = []

                # convert builders from objects to config dictionaries
                builders_dicts = []
                for b in builders:
                    if isinstance(b, buildbot.config.BuilderConfig):
                        builders_dicts.append(b.getConfigDict())
                    elif type(b) is dict:
                        builders_dicts.append(b)
                    else:
                        raise ValueError(
                            "builder %s is not a BuilderConfig object (or a dict)"
                            % b)
                builders = builders_dicts

                for b in builders:
                    if b.has_key(
                            'slavename') and b['slavename'] not in slavenames:
                        raise ValueError("builder %s uses undefined slave %s" \
                                         % (b['name'], b['slavename']))
                    for n in b.get('slavenames', []):
                        if n not in slavenames:
                            raise ValueError("builder %s uses undefined slave %s" \
                                             % (b['name'], n))
                    if b['name'] in buildernames:
                        raise ValueError("duplicate builder name %s" %
                                         b['name'])
                    buildernames.append(b['name'])

                    # sanity check name (BuilderConfig does this too)
                    if b['name'].startswith("_"):
                        errmsg = ("builder names must not start with an "
                                  "underscore: " + b['name'])
                        log.err(errmsg)
                        raise ValueError(errmsg)

                    # Fix the dictionnary with default values, in case this wasn't
                    # specified with a BuilderConfig object (which sets the same defaults)
                    b.setdefault('builddir',
                                 buildbot.util.safeTranslate(b['name']))
                    b.setdefault('slavebuilddir', b['builddir'])

                    if b['builddir'] in dirnames:
                        raise ValueError("builder %s reuses builddir %s" %
                                         (b['name'], b['builddir']))
                    dirnames.append(b['builddir'])

                unscheduled_buildernames = buildernames[:]
                schedulernames = []
                for s in schedulers:
                    for b in s.listBuilderNames():
                        assert b in buildernames, \
                               "%s uses unknown builder %s" % (s, b)
                        if b in unscheduled_buildernames:
                            unscheduled_buildernames.remove(b)

                    if s.name in schedulernames:
                        # TODO: schedulers share a namespace with other Service
                        # children of the BuildMaster node, like status plugins, the
                        # Manhole, the ChangeMaster, and the BotMaster (although most
                        # of these don't have names)
                        msg = ("Schedulers must have unique names, but "
                               "'%s' was a duplicate" % (s.name, ))
                        raise ValueError(msg)
                    schedulernames.append(s.name)

                if unscheduled_buildernames:
                    log.msg(
                        "Warning: some Builders have no Schedulers to drive them:"
                        " %s" % (unscheduled_buildernames, ))

                # assert that all locks used by the Builds and their Steps are
                # uniquely named.
                lock_dict = {}
                for b in builders:
                    for l in b.get('locks', []):
                        if isinstance(l, locks.LockAccess
                                      ):  # User specified access to the lock
                            l = l.lockid
                        if lock_dict.has_key(l.name):
                            if lock_dict[l.name] is not l:
                                raise ValueError(
                                    "Two different locks (%s and %s) "
                                    "share the name %s" %
                                    (l, lock_dict[l.name], l.name))
                        else:
                            lock_dict[l.name] = l
                    # TODO: this will break with any BuildFactory that doesn't use a
                    # .steps list, but I think the verification step is more
                    # important.
                    for s in b['factory'].steps:
                        for l in s[1].get('locks', []):
                            if isinstance(
                                    l, locks.LockAccess
                            ):  # User specified access to the lock
                                l = l.lockid
                            if lock_dict.has_key(l.name):
                                if lock_dict[l.name] is not l:
                                    raise ValueError(
                                        "Two different locks (%s and %s)"
                                        " share the name %s" %
                                        (l, lock_dict[l.name], l.name))
                            else:
                                lock_dict[l.name] = l

                if not isinstance(properties, dict):
                    raise ValueError("c['properties'] must be a dictionary")

                # slavePortnum supposed to be a strports specification
                if type(slavePortnum) is int:
                    slavePortnum = "tcp:%d" % slavePortnum

                # now we're committed to implementing the new configuration, so do
                # it atomically
                # TODO: actually, this is spread across a couple of Deferreds, so it
                # really isn't atomic.

                d = defer.succeed(None)

                self.projectName = projectName
                self.projectURL = projectURL
                self.buildbotURL = buildbotURL

                self.properties = Properties()
                self.properties.update(properties, self.configFileName)

                self.status.logCompressionLimit = logCompressionLimit
                self.status.logCompressionMethod = logCompressionMethod
                self.status.logMaxSize = logMaxSize
                self.status.logMaxTailSize = logMaxTailSize
                # Update any of our existing builders with the current log parameters.
                # This is required so that the new value is picked up after a
                # reconfig.
                for builder in self.botmaster.builders.values():
                    builder.builder_status.setLogCompressionLimit(
                        logCompressionLimit)
                    builder.builder_status.setLogCompressionMethod(
                        logCompressionMethod)
                    builder.builder_status.setLogMaxSize(logMaxSize)
                    builder.builder_status.setLogMaxTailSize(logMaxTailSize)

                if mergeRequests is not None:
                    self.botmaster.mergeRequests = mergeRequests
                if prioritizeBuilders is not None:
                    self.botmaster.prioritizeBuilders = prioritizeBuilders

                self.buildCacheSize = buildCacheSize
                self.eventHorizon = eventHorizon
                self.logHorizon = logHorizon
                self.buildHorizon = buildHorizon

                # self.slaves: Disconnect any that were attached and removed from the
                # list. Update self.checker with the new list of passwords, including
                # debug/change/status.
                d.addCallback(lambda res: self.loadConfig_Slaves(slaves))

                # self.debugPassword
                if debugPassword:
                    self.checker.addUser("debug", debugPassword)
                    self.debugPassword = debugPassword

                # self.manhole
                if manhole != self.manhole:
                    # changing
                    if self.manhole:
                        # disownServiceParent may return a Deferred
                        d.addCallback(
                            lambda res: self.manhole.disownServiceParent())

                        def _remove(res):
                            self.manhole = None
                            return res

                        d.addCallback(_remove)
                    if manhole:

                        def _add(res):
                            self.manhole = manhole
                            manhole.setServiceParent(self)

                        d.addCallback(_add)

                # add/remove self.botmaster.builders to match builders. The
                # botmaster will handle startup/shutdown issues.
                d.addCallback(lambda res: self.loadConfig_Builders(builders))

                d.addCallback(lambda res: self.loadConfig_status(status))

                # Schedulers are added after Builders in case they start right away
                d.addCallback(
                    lambda res: self.loadConfig_Schedulers(schedulers))
                # and Sources go after Schedulers for the same reason
                d.addCallback(
                    lambda res: self.loadConfig_Sources(change_sources))

                # self.slavePort
                if self.slavePortnum != slavePortnum:
                    if self.slavePort:

                        def closeSlavePort(res):
                            d1 = self.slavePort.disownServiceParent()
                            self.slavePort = None
                            return d1

                        d.addCallback(closeSlavePort)
                    if slavePortnum is not None:

                        def openSlavePort(res):
                            self.slavePort = strports.service(
                                slavePortnum, self.slaveFactory)
                            self.slavePort.setServiceParent(self)

                        d.addCallback(openSlavePort)
                        log.msg("BuildMaster listening on port %s" %
                                slavePortnum)
                    self.slavePortnum = slavePortnum

                log.msg("configuration update started")

                def _done(res):
                    self.readConfig = True
                    log.msg("configuration update complete")

                d.addCallback(_done)
                d.addCallback(lambda res: self.botmaster.maybeStartAllBuilds())
                return d
Пример #8
0
def Update(config, active_master, c):
    # Polls config.Master.trunk_url for changes
    c['change_source'].append(PBChangeSource())
Пример #9
0
 def __init__(self, *args, **kwargs):
     PBChangeSource.__init__(self, *args, **kwargs)
Пример #10
0
def master(title,
           buildbotURL,
           slaves,
           projects,
           titleURL=None,
           slavePortnum=9989,
           change_source=None,
           passwd_path=None,
           status=[]):

    # projects can be a module name whose submodules each describe a
    # project by exporting attributes
    if isinstance(projects, str):
        lazy_reload(projects)
        p = []
        from util import load_submodules
        import project
        for m in load_submodules(projects):
            p.append(project.from_module(m))
        projects = p

    c = {}

    ####### PASSWORDS

    # If you have chosen not to store passwords directly in the .cfg
    # file, you can provide the path to a passwords file that will be
    # parsed here.
    if passwd_path is None:
        passwd_path = os.path.join(
            os.path.dirname(os.path.dirname(os.path.dirname(__file__))),
            'passwd')

    passwords = None
    if os.path.isfile(passwd_path):
        passwords = dict(line.rstrip().split(':')
                         for line in open(passwd_path))

    ####### BUILDSLAVES

    # The 'slaves' list defines the set of recognized buildslaves. Each
    # element is a BuildSlave object, specifying a unique slave name and
    # password.  The same slave name and password must be configured on
    # the slave.

    for s in slaves:
        s.prepare(passwords)
    c['slaves'] = slaves

    # 'slavePortnum' defines the TCP port to listen on for connections from slaves.
    # This must match the value configured into the buildslaves (with their
    # --master option)
    c['slavePortnum'] = slavePortnum

    ####### CHANGESOURCES

    # the 'change_source' setting tells the buildmaster how it should find out
    # about source code changes. Any class which implements IChangeSource can be
    # put here: there are several in buildbot/changes/*.py to choose from.

    # This is the one used for BoostPro git repo changes
    c['change_source'] = change_source or PBChangeSource()

    ####### SCHEDULERS

    for p in projects:
        p.select_slaves(c['slaves'])

    # Configure the Schedulers, which decide how to react to incoming changes.
    c['schedulers'] = flatten(p.schedulers for p in projects)

    ####### BUILDERS

    # The 'builders' list defines the Builders, which tell Buildbot how to perform a build:
    # what steps, and which slaves can execute them.  Note that any particular build will
    # only take place on one slave.

    c['builders'] = flatten(p.builders for p in projects)

    c['mergeRequests'] = False

    ####### STATUS TARGETS

    # 'status' is a list of Status Targets. The results of each build will be
    # pushed to these targets. buildbot/status/*.py has a variety to choose from,
    # including web pages, email senders, and IRC bots.
    c['status'] = flatten([s1(p1) for s1 in p1.status]
                          for p1 in projects) + status

    ####### PROJECT IDENTITY

    # the 'projectName' string will be used to describe the project that this
    # buildbot is working on. For example, it is used as the title of the
    # waterfall HTML page. The 'projectURL' string will be used to provide a link
    # from buildbot HTML pages to your project's home page.

    c['projectName'] = title
    c['projectURL'] = titleURL or buildbotURL

    # the 'buildbotURL' string should point to the location where the buildbot's
    # internal web server (usually the html.WebStatus page) is visible. This
    # typically uses the port number set in the Waterfall 'status' entry, but
    # with an externally-visible host name which the buildbot cannot figure out
    # without some help.

    c['buildbotURL'] = buildbotURL.rstrip('/') + '/'

    ####### DB URL

    # This specifies what database buildbot uses to store change and scheduler
    # state.  You can leave this at its default for all but the largest
    # installations.
    c['db_url'] = "sqlite:///state.sqlite"

    return c
 def __init__(self, comparator, *args, **kwargs):
   self.comparator = comparator
   PBChangeSource.__init__(self, *args, **kwargs)
Пример #12
0
# master with this protocol.
# 'port' must match the value configured into the buildslaves (with their
# --master option)

c['protocols'] = {'pb': {'port': 9989}}

# CHANGESOURCES
# List of sources to retrieve change notifications from.
# We get our sources from notifications sent by the github hook bot on a port.

from buildbot.changes.pb import PBChangeSource
from infostore import change_source_credentials

c['change_source'] = [
    PBChangeSource(
        user=change_source_credentials[0][0],
        passwd=change_source_credentials[0][1],
    )
]

# BUILDERS
# List of builds and their build steps

from buildbot.config import BuilderConfig

c['builders'] = [
    BuilderConfig(name="windows-x64-builder",
                  slavenames=["windows-x64-slave-1"],
                  factory=construct_nim_build(
                      csources_script_cmd='build64.bat', platform='windows')),
    BuilderConfig(name="windows-x32-builder",
                  slavenames=["windows-x32-slave-1"],
Пример #13
0
            max_builds=1),
     Worker("delroth-nuc",
            BUILDSLAVES_PASSWORDS["delroth-nuc"],
            max_builds=1),
     Worker("delroth-vm-ubuntu-radeon",
            BUILDSLAVES_PASSWORDS["delroth-vm-ubuntu-radeon"],
            max_builds=1),
     Worker("hive", BUILDSLAVES_PASSWORDS["hive"]),
 ],
 "protocols": {
     "pb": {
         "port": 9989
     },
 },
 "change_source": [
     PBChangeSource(user="******", passwd=CHANGESOURCE_PASSWORD),
 ],
 "schedulers": [
     win64_release,
     win64_debug,
     osx_release,
     deb64_release,
     ubu64_release,
     android_release,
     freebsd_release,
     Triggerable(name="fifoci-lin",
                 builderNames=[
                     "fifoci-ogl-lin-intel",
                     "fifoci-ogl-lin-mesa",
                     "fifoci-ogl-lin-nouveau",
                     "fifoci-ogl-lin-nv",