简体   繁体   English

Jenkins用git稀疏结账触发

[英]Jenkins triggers with git sparse checkout

I have a big git repository and I created multiple jobs for it in Jenkins. 我有一个很大的git存储库,我在Jenkins中为它创建了多个作业。
I used git sparse checkout feature to sync each time only the necessary part of it. 我使用git sparse checkout功能每次只同步它的必要部分。
Also I hoped that the SCM polling function would trigger only when the changes happen on the related part of the code. 此外,我希望只有在代码的相关部分发生更改时才会触发SCM轮询功能。 In fact it is triggering all the jobs whatever the commit is on. 实际上,无论提交什么,它都会触发所有作业。

My Question : How can I ensure a job is triggered only when its related files are changed ? 我的问题:如何确保只在相关文件发生变化时触发作业?
Also, would a switch from "Jenkins polling GIT" to "trigger from Gitlab" allow solve this ? 此外,从“Jenkins轮询GIT”切换到“从Gitlab触发”是否可以解决这个问题?

There is an option under the Additional Behaviours dropdown list of the Jenkins Git Plugin called Polling ignores commit in certain paths. 在Jenkins Git插件的Additional Behaviours下拉列表下有一个选项,名为Polling ignores commit in certain paths. There you can specify included and excluded paths to control the behavior of SCM polling. 在那里,您可以指定包含和排除的路径来控制SCM轮询的行为。

From the Plugin's documentation: 从插件的文档:

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.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM