我是 BuildBot 的新手,并尝试从master.cfg实现构建过程。
我创建了常用的python包,可以在build-process,
中使用因此,在util.BuildFactory()
中添加步骤时,我想从自定义构建包中执行python方法。
我审阅了Adding customized functions to Buildbot。
我在buildbot中的master.cfg中导入了我的自定义包,
但仍然无法直接从factory.addStep
调用该方法。
我有另一种选择,比如创建python脚本,导入该自定义构建实用程序包,然后从steps.ShellCommand(command=['python', 'myScript.py'])
执行该脚本
但是对于特定的构建过程会有额外的脚本维护,我不能重用该脚本。
所以从BUILDBOT的构建过程中调用PYTHON方法是什么。
答案 0 :(得分:0)
要从buildbot调用自定义python脚本,需要在master.cfg中进行一些配置更改
BUILDBOT安装步骤
1] virtualenv -p python3 buildbotenv
2] mkdir ~/Documents/Buildbot/master
3] source buildbotenv/bin/activate
4] pip install --upgrade pip
5] pip install 'buildbot[bundle]'
6] buildbot create-master <Folder Name>
buildbot create-master master
7] cp master/master.cfg.sample master/master.cfg
8] buildbot start master
9] pip install buildbot-worker
10] pip install setuptools-trial
11] buildbot-worker create-worker worker localhost example-worker pass
12] buildbot-worker start worker
master.cfg
from buildbot.plugins import *
from buildbot.plugins import steps, util
c = BuildmasterConfig = {}
####### WORKERS
c['workers'] = [worker.Worker("example-worker", "pass")]
c['protocols'] = {'pb': {'port': 9989}}
####### CHANGESOURCES
c['change_source'] = []
c['change_source'].append(changes.GitPoller(
'git://<GIT URL>',
workdir='gitpoller-workdir', branch='bugfix',
pollInterval=300))
####### SCHEDULERS
c['schedulers'] = []
c['schedulers'].append(schedulers.SingleBranchScheduler(
name="all",
change_filter=util.ChangeFilter(branch='bugfix'),
treeStableTimer=None,
builderNames=["runtests"]))
c['schedulers'].append(schedulers.ForceScheduler(
name="force",
builderNames=["runtests"]))
####### BUILDERS
factory = util.BuildFactory()
factory.addStep(steps.Git(repourl='git://<GIT URL>', mode='incremental'))
factory.addStep(steps.ShellCommand(command=["trial", "hello"],
env={"PYTHONPATH": "."}))
c['builders'] = []
call_python_script = steps.ShellCommand(name="call_python_script",
description="call_python_script",
command="sh ~/Documents/Buildbot/deployment.py",
haltOnFailure=True)
f_simplebuild = util.BuildFactory()
#f_simplebuild.addStep(create_file)
f_simplebuild.addStep(call_python_script)
#This will be the comman
c['builders'].append(
util.BuilderConfig(name="runtests",
workernames=["example-worker"],
factory=f_simplebuild))
####### BUILDBOT SERVICES
c['services'] = []
####### PROJECT IDENTITY
c['title'] = "BUILD BOT"
c['titleURL'] = "https://buildbot.github.io/hello-world/"
c['buildbotURL'] = "http://localhost:8010/"
# minimalistic config to activate new web UI
c['www'] = dict(port=8010,
plugins=dict(waterfall_view={}, console_view={}, grid_view={}))
####### DB URL
c['db'] = {
'db_url' : "sqlite:///state.sqlite",
}