Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

For a particular scenario my requirement is, lets suppose we have 2 folders:
Folder 1
Folder 2
If there is a change in a file of "Folder 1", then the Jenkins build should trigger, otherwise it should not. I am using Git repository to maintain my code.

I would request any help if someone has been through this scenario.

Thanks and Regards,
Rahul

What I have tried:

Gone through many solutions online for ex:
https://stackoverflow.com/questions/28332780/how-to-trigger-a-jenkins-build-in-gerrit-trigger-on-change-to-project-subdirecto[^]

In Jenkin's under "dynamic source triggering" option, specified "file path", "forbidden file path" option. However, i see that my Jenkins Job is getting triggered for changes within both Folder-1 and Folder-2.

The configuration which i have set is:
GERRIT TRIGGER:
Trigger On:
- Draft Published
- Patchset Created

DYNAMIC TRIGGER CONFIGURATION:
Gerrit Project: name of repo: repo_name
Branches: path of the branch : for ex: /path
Add File path: Folder-1/**

Reading the documentation part, i saw that in Forbidden file paths, if there is a change in only the forbidden file, the Job wont trigger. But, somehow it doesnot seem to work.

Also, please note, that i use a sparse checkout, to checkout specific folders from the repository. I dont know, if that can affect...
Posted
Updated 19-Mar-23 2:32am
v2

1 solution

Hello All,

I got it to work, by doing the below:
1. Remove forbidden file path - There is no need of that
2. Just keep the file path - Specify the path of the folder within which you want your to trigger if there is some change for ex:
mypath/**

Now, when you update a file within the required folder i.e Folder1 in my case, then a gerrit review is created and the first patchset is upload and subsequently my Job is triggered.

Then, when i update a file within Folder2, then the 2nd patchset is uploaded and even then my Job is triggered. This is because the required file is still in my Gerrit review.

For, my job to stop triggering, i removed my file from the review and it started behaiving properly.

If any one has any other opinion, please post.

Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900