Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Get pull request id by commit hash

Lubomir Stoimchev July 10, 2020

Hello,

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.

2 answers

0 votes
Aaron Mailhot October 30, 2023

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.

0 votes
Oweis Al-Agtash November 16, 2020

Hello, 

Have you found a way so far? 

I also need PR ID for a similar use case.

 

Many Thanks in advance!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events