Jenkins用git稀疏结账触发

时间:2016-07-05 11:34:42

标签: git jenkins triggers

我有一个很大的git存储库,我在Jenkins中为它创建了多个工作 我使用git sparse checkout功能每次只同步它的必要部分 此外,我希望只有在代码的相关部分发生更改时才会触发SCM轮询功能。事实上,无论提交的是什么,它都会触发所有工作。

我的问题:如何确保只在相关文件发生变化时触发作业? 此外,从“Jenkins轮询GIT”切换到“从Gitlab触发”是否可以解决这个问题?

1 个答案:

答案 0 :(得分:5)

Jenkins Git插件的Additional Behaviours下拉列表中有一个名为Polling ignores commit in certain paths.的选项,您可以指定包含和排除的路径来控制SCM轮询的行为。

从插件的文档:

Each inclusion uses regular expression pattern matching, and must be separated by a new line.
An empty list implies that everything is included.

    myapp/src/main/web/.*\.html
    myapp/src/main/web/.*\.jpeg
    myapp/src/main/web/.*\.gif

The example above illustrates that a build will only occur, if html/jpeg/gif files have been committed to the SCM.
Exclusions take precedence over inclusions, if there is an overlap between included and excluded regions.