Buildbot 如何处理多个构建器

Buildbot how to handle multiple builders

我已按照本教程在 FreeBSD 12.1 上设置我的 buildbot 服务器:

https://www.digitalocean.com/community/tutorials/how-to-build-and-deploy-packages-for-your-freebsd-servers-using-buildbot-and-poudriere

在我更改教程如何处理工人数组后,服务器正在使用 poudriere 工作和构建。

我在文件 /var/buildbot-master/master.cfg:

中针对我的场景调整了教程说明,如下所示
. . .
####### SCHEDULERS

c['schedulers'] = []

# Forceful scheduler allowed for all builders
c['schedulers'].append(schedulers.ForceScheduler(
    name='force',
    builderNames=[builder.name for builder in c['builders']]))

# Watch ports tree for changes on given branch
c['schedulers'].append(schedulers.SingleBranchScheduler(
    name='sched-bulk-121amd64-2020Q2',
    change_filter=util.ChangeFilter(project='freebsd-ports', branch='branches/2020Q2'),
    builderNames=['bulk-121amd64-2020Q2']))
. . .

此行在启动时给出错误:

builderNames=[builder.name for builder in c['builders']]))

我不知道 pyhton,但在我看来这是一个 for 来获取所有 builder names数组...

错误信息是:

2020-09-16 15:33:18-0300 [-] twistd 20.3.0 (/usr/local/bin/python3.7 3.7.9) starting up.
2020-09-16 15:33:18-0300 [-] reactor class: twisted.internet.pollreactor.PollReactor.
2020-09-16 15:33:18-0300 [-] Starting BuildMaster -- buildbot.version: 2.7.0
2020-09-16 15:33:18-0300 [-] Loading configuration from '/var/buildbot-master/master.cfg'
2020-09-16 15:33:18-0300 [-] error while parsing config file:
        Traceback (most recent call last):
          File "/usr/local/lib/python3.7/site-packages/twisted/python/threadpool.py", line 266, in <lambda>
            inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
          File "/usr/local/lib/python3.7/site-packages/twisted/python/context.py", line 122, in callWithContext
            return self.currentContext().callWithContext(ctx, func, *args, **kw)
          File "/usr/local/lib/python3.7/site-packages/twisted/python/context.py", line 85, in callWithContext
            return func(*args,**kw)
          File "/usr/local/lib/python3.7/site-packages/buildbot/config.py", line 170, in loadConfig
            self.basedir, self.configFileName)
        --- <exception caught here> ---
          File "/usr/local/lib/python3.7/site-packages/buildbot/config.py", line 128, in loadConfigDict
            execfile(filename, localDict)
          File "/usr/local/lib/python3.7/site-packages/twisted/python/compat.py", line 247, in execfile
            exec(code, globals, locals)
          File "/var/buildbot-master/master.cfg", line 103, in <module>
            builderNames=[builder.name for builder in c['builders']]))
        builtins.KeyError: 'builders'

2020-09-16 15:33:18-0300 [-] Configuration Errors:
2020-09-16 15:33:18-0300 [-]   error while parsing config file: 'builders' (traceback in logfile)
2020-09-16 15:33:18-0300 [-] Halting master.
2020-09-16 15:33:18-0300 [-] BuildMaster startup failed
2020-09-16 15:33:18-0300 [-] BuildMaster is stopped
2020-09-16 15:33:18-0300 [-] Main loop terminated.
2020-09-16 15:33:18-0300 [-] Server Shut Down.

以下部分哪里做出改变:

          File "/var/buildbot-master/master.cfg", line 103, in <module>
            builderNames=[builder.name for builder in c['builders']]))
        builtins.KeyError: 'builders'

2020-09-16 15:33:18-0300 [-] Configuration Errors:
2020-09-16 15:33:18-0300 [-]   error while parsing config file: 'builders' (traceback in logfile)
2020-09-16 15:33:18-0300 [-] Halting master.

所以,我已经硬编码了参数,而不是检查数组:

builderNames=[builder.name for builder in c['builders']]))

收件人:

builderNames=['bulk-121amd64-2020Q2']))

然后buildbot开始无错,可以运行 poudriere.

我的问题是

正确的语法 应该是什么检查 数组 c['builders' ] 让它动态而不是硬编码?

尝试了很多 python 教程中的示例,但都没有成功。

默认情况下 master.cfg.sample,结构 c['builders']c['schedulers'] 之后创建,这就是它在您的代码中未定义的原因。

尝试将(移动)BUILDERS 块放在 SCHEDULERS 块之前。