简体   繁体   中英

Jenkins triggers with git sparse checkout

I have a big git repository and I created multiple jobs for it in Jenkins.
I used git sparse checkout feature to sync each time only the necessary part of it.
Also I hoped that the SCM polling function would trigger only when the changes happen on the related part of the code. 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 ?

There is an option under the Additional Behaviours dropdown list of the Jenkins Git Plugin called Polling ignores commit in certain paths. There you can specify included and excluded paths to control the behavior of SCM polling.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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