0
votes

I have a bit different requirement. I have a Jenkins job that is being triggered by a webhook. It is a Post Receive hook in the Bitbucket.

The webhook works and the job get triggered. The thing is the job needs to edit a file in the repo and then commit the same file back to the repo. This also works, but once the file is pushed to the repo, it triggers another build in Jenkins. Leading to chain reaction scenario.

What I want to do here is, when I commit and push the file from the Jenkins job, the file should get pushed to the repo, but the webhook should not trigger for this particular file. If any other file is modified and pushed, the webhook should trigger and hence the Jenkins job as well.

Is there any configuration that we can do in the Bitbucket webhook so that if simply do not trigger if a particular file is pushed?

1
Can't you add a check to the hook to see if the file is modified? Who is the author in the Jenkins commit? If unique you could check the author.EncryptedWatermelon
I want to push the file for sure, and that file will be definitely modified by the Jenkins job every time it runs. Regarding the user, the same user will be committing and pushing the files to repo in multiple scenarios, so if I ignore that user, the actual push (correct one) that should trigger the hook will not trigger the hook.Omkar
I think in theory you could add a "recurse" parameter to the Jenkins job to stop this behavior.alex

1 Answers

-1
votes

I think you should get rid of

The thing is the job needs to edit a file in the repo and then commit the same file back to the repo

this in the first place. Make your life to complicated.

On the other hand. Bitbucket push events hands out a lot of information. if you use generic webhook trigger plugin. You can read out all this information an make your decision based on the data.