Issue
I have a git repository where I have created two different jobs in Jenkins (one for production code and one for tools). Where both jobs always are triggered!
I have added Excluded Regions for each jobs to only trigger on each correct folder.
Our git root folder contains the following:
/src/
/tools/
/test/
/doc/
/third party/
In my Source job in Jenkins I have the following Excluded Regions
/tools/.*
/Test Projects/.*
/doc/.*
In my tools job I have the folling Excluded Regions
/src/.*
/Test Projects/.*
/doc/.*
The problem is that if I push a change in doc-folder both jobs are triggered. I don't have any include regions either.
Solution
This setup should work.
However if you are using Gerrit Triggers in Jenkins the exclude/include regions in GitSCM plugin will not work. In the Gerrit Trigger plugin there is an option to add file paths which will work like an include region, i.e. the build will only get triggered when there is a change in the file path added.
In the Gerrit trigger configuration of your job add a file path like below to include tools directory.
Path tools/**
Answered By - MattiasH
Answer Checked By - Marilyn (JavaFixing Volunteer)