'Jenkins to detect Pull Request from a forked branch in Bitbucket

I have a bitbucket server that has a webhook configured with Jenkins.

Bitbucket has a master branch in it. I made changes in the local branch (let's call local_branch). When I git push --set-upstream origin local_branch this will create a forked branch in the bitbucket server.

My Jenkins cannot access the forked branch local_branch (which contains my changes) even though I added Jenkins as a user and give it read permission to my master branch. Unless I gave Jenkins read access to my forked branch, then my Jenkins can access the forked branch.

This is not intelligent if each one creates a forked branch and has to manually add Jenkins into the forked branch he/she created on the bitbucket server.

My goal is to let Jenkins trigger the job towards each person's forked branch whenever one creates a pull request from his/her forked branch on top of master branch.

Just wondering if anyone has ever encountered this.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source