You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Do anyone know how to get the pull request ID based on the commit's hash?
I'm triggering a jenkins job via http webhook. Once the job ends, if there is a problem I want to mark the PR as "needs work".
I've found a working API call (https://docs.atlassian.com/bitbucket-server/rest/6.0.2/bitbucket-rest.html#idp288) but I need to provide the PR ID.
Unfortunately the HTTP webhook plugin does not provide such property.
I realize it is not quite the answer you requested, but do you use or have you considered using multi-branch pipelines in Jenkins? With multi-branch pipelines, you are automatically hooked into BitBucket such that the failed build will cause the failure to be seen on the BitBucket PR and you can readily have your merge checks 'block' on that failure as in users have to get the job passing before the PR can be merged.
You can also then do more custom behavior if desired, including getting the PR ID from the Jenkins CHANGE_ID and BRANCH_NAME environment variables and sending info to that API endpoint if the built-in hooks are insufficient for your needs.