API to check whether a PR can be merged or not?

Siddharth Agrawal
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 11, 2023

As part of the CI/CD pipeline, we want to validate whether a PR passes configured merge checks and is not in any conflict. I went through the cloud Rest documentation, but didn't find any api.

I see bitbucket ui makes a api call to /merge-restriction to get this info. Is there a similar api to consume?

If not what other alternatives I have to check whether a PR can be merged or not?

2 answers

1 vote
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 12, 2023

Hello @Siddharth Agrawal and welcome to the Community!

I'm afraid that for pull request merge check status in particular, Bitbucket Cloud currently doesn't expose a public API endpoint. We do have an open feature request to make this information available on the API, which you can find below : 

I would suggest you to add your Vote there, since this helps both developers and product managers to understand the interest. Also, make sure you add yourself as a Watcher in case you want to receive first-hand updates from that ticket.

For getting the PR diff conflicts though, our development team is working on building a direct endpoint to fetch that information, but in the meanwhile you can use the Get Pull Request API  endpoint to get the PR, and use the source and destination commit data to construct a direct diffstat request which will return the conflict status as part of the object.

Hope that helps! If you have any questions, please let us know.

Thank you, @Siddharth Agrawal !

Patrik S

0 votes
Saxea _Flowie_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 12, 2023

Hi @Siddharth Agrawal,

Depending on what you are trying to do you should be able to achieve with Flowie, and if not, I'm happy to discuss and possibly add support for it. 

Are you trying to run a pipeline only if certain conditions are met? E.g. only build after a review is complete?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events