有没有办法配置 master.cfg 来安排构建器在项目文件夹或文件被修改(或其 FileVersionInfo 更改)时执行代码?
我知道这是一个很好的解决方法,但是我需要这个来在开发人员编译了一个新版本的产品之后立即运行构建验证测试,并且由于许多项目的开发不在 CVS 中,我需要一个扫描仪项目文件夹。
以下是 master.cfg 的摘录:
def create_builders_and_schedule_it(factory, build_slaves, **kwargs):
# kwargs: change_filter=None, nightly=None, trigger_name=None)
builder_names = []
if hasattr(factory, 'subcategory'):
cat = "%s_%s" % (factory.category, factory.subcategory)
else:
cat = factory.category
if 'change_filter' in kwargs:
change_filter = kwargs['change_filter']
else:
change_filter = filter.ChangeFilter( branch = factory.branch )
for i_slave in build_slaves:
builder_name = "%s_%s" % (cat, i_slave)
builder_names.append(builder_name)
c['builders'].append(
BuilderConfig(name = builder_name,
category = factory.category,
factory = factory,
slavename = i_slave
))
# every task has 'forced' scheduler at least
c['schedulers'].append(
ForceScheduler(name = cat + "_force",
builderNames = builder_names))
# every task has 'on commit' scheduler
c['schedulers'].append(
SingleBranchScheduler(name = cat + "_singlebranch",
builderNames = builder_names,
change_filter = change_filter))
# some task can be scheduled
if 'nightly' in kwargs:
c['schedulers'].append( timed.Nightly(
name = cat + '_nightly',
branch = factory.branch,
builderNames = builder_names,
hour = kwargs['nightly'][0], minute = kwargs['nightly'][1]))
if 'trigger_name' in kwargs:
c['schedulers'].append(
Triggerable(
name = kwargs['trigger_name'],
builderNames = builder_names))
有一个从 BuildFactory 派生的典型类:
class Autotests(BuildFactory):
""" Build products from Autotests repository """
def __init__(self, branch):
BuildFactory.__init__(self)
self.category = "autotests"
self.branch = branch
self.addStep(
Git(repourl = AUTOTESTS_REPO, branch = branch))
def build_source_archive(self):
self.subcategory = "source"
self.addStep(
ShellCommand(
workdir = "build",
command = ["./upload_to_binary_repo.sh"]))
return self
def run_BVT_prod(self):
self.subcategory = "BVT_prod"
self.addStep(
ShellCommand(
workdir = "build/BVT_tests/prod",
env = {'PATH':"/usr/bin:/bin", 'VIRTUAL_ENV':''},
command = ["./bvt_runner.sh"] ))
return self
现在我们有了方法和类,我们
create_builders_and_schedule_it(
Autotests("devel").run_BVT_Prod(),
['VIX_runner'],
nightly = (2,0)
)
有没有一种通用的方法来执行这种检查?还是我应该往另一个方向看?