Reputation: 741
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 ?
Upvotes: 6
Views: 2602
Reputation: 4030
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.
Upvotes: 7