如何在buildbot中触发Git仓库子目录中的更改的构建

时间:2016-12-13 02:23:49

标签: buildbot

假设你有一个这种结构的回购:

myrepo/project1
myrepo/project2

如何配置buildbot,以便只在myrepo / project1中进行更新时触发构建?

以下是示例配置我在整个仓库中触发了:

step_build = steps.ShellCommand(name='somebuildcommand',
        command=['some', 'build', 'command'],
        workdir="build/",
        description='some build command')

factory = util.BuildFactory()
# check out the source
factory.addStep(steps.Git(repourl='https://github.com/some/myrepo.git', mode='incremental'))
factory.addStep(step_build)

c['builders'] = []
c['builders'].append(
    util.BuilderConfig(name="runtests",
      workernames=["example-worker"],
      factory=factory))

1 个答案:

答案 0 :(得分:1)

好的,我自己想到这一点,基本上需要配置调度程序,只触发“重要”文件,例如:

def file_is_important(change):
    if not change.files:
        return False
    for file in change.files:
        if file.startswith('important-dir/'):
            print 'detected important changes:', change.files
            return True
    return False

c['schedulers'] = []
c['schedulers'].append(schedulers.SingleBranchScheduler(
                            name="all",
                            fileIsImportant=file_is_important,
                            change_filter=util.ChangeFilter(branch='master'),
                            treeStableTimer=None,
                            builderNames=["builder"]))