Jenkins使用git sparse checkout进行触发

6

我有一个很大的Git仓库,并在Jenkins中创建了多个作业。
我使用了Git的稀疏检出功能,每次只同步必要的部分。
此外,我希望SCM轮询功能仅在相关代码部分发生更改时触发。实际上,它会触发所有作业,无论提交是否有关。

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

1个回答

7

在Jenkins Git插件的“其他行为”下拉列表中有一个选项,称为“轮询忽略某些路径中的提交”。在那里,您可以指定包含和排除的路径以控制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.

谢谢!我在“附加行为->特定路径中忽略提交”的选项中找到了它。你能否更新你的答案,这样我就可以将其标记为“已接受”? - Gurvan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接