How to get list of pull requests a commit is part of?

David Karr
Contributor
July 21, 2018

(I tried to post this earlier today, but I don't see it anywhere, so I guess it didn't work somehow.)

I'm using BitBucket Server v4.9.0.

I want to get the list of pull requests that a commit is part of.

I went to the top-level REST api docs, at https://docs.atlassian.com/bitbucket-server/rest/5.12.0/bitbucket-rest.html#idm45885143329280 .  Now that I'm looking at this URL, I wonder if 5.12.0 represents the API version, which is newer than 4.9.0, which is perhaps why what I'm trying to do isn't working.

In any case, this page clearly says that I can get the pull requests from the commit, but when I use this URL, I get a 404.  I tried removing "pull-requests", and that doesn't fail, it just gives me information about the commit itself.

Until our enterprise upgrades to a newer release, is there some other way I can use the API to get the list of pull requests a commit is on?

2 answers

1 vote
Julius Davies _bit-booster_com_
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.
July 21, 2018

Regarding this REST endpoint:

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/pull-requests

You are correct:  that REST endpoint is not available in Bitbucket Server version 4.9.0.

It's not even available in version 5.10.0 of Bitbucket Server.  The earliest version where I could locate that REST endpoint is Bitbucket Server 5.11.1:

https://docs.atlassian.com/bitbucket-server/rest/5.11.1/bitbucket-rest.html#idm46358292211472

 

One question:  are you trying to locate pull-requests associated with a commit BEFORE the pull-request is merged, or after?  (Or both?)

0 votes
David Karr
Contributor
July 21, 2018

I can see it being useful to get this info both before and after merging.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events