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

Bitbucket Cloud REST API to list all commit messages between two branches/tags/commits

Frank Fu November 21, 2017

Hi,

I'm trying to generate a list of commit messages between either two branches or two commits for the purposes of generating release notes as part of our CI/CD pipeline.

Ideally, we want a text version of an output like this

https://bitbucket.org/ged/ruby-pg/branches/compare/default%0Dstable

So is example, this page gives us all the commit messages between the two branches default and stable

I've found this documentation 

https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/diff/%7Bspec%7D

But it is way too verbose for my use case.

 

 

 

 

2 answers

1 vote
csomme
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 4, 2017

HI Frank,

 https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commits

Is the commits endpoint that should give you the information you're looking for. It is going to return it as JSON. If you're really only interested in the commit messages you can customize the fields that come back. See https://developer.atlassian.com/bitbucket/api/2/reference/meta/partial-response. 

Combining those things, to get the commit messages between a feature branch and the master branch might look something like this:

 https://api.bitbucket.org/2.0/repositories/get/ruby-pg/commits/stable?exclude=stable&fields=values.message,next

Which gives you just the commit message and a link to follow (the API is paginated).

Frank Fu December 4, 2017

Hi @csomme,

Thanks for your response! Very handy.. though sometimes I need to compare feature1 with feature2? Is that possible?

abourg September 19, 2019

Any idea how to do this on Bitbucket Server?

0 votes
Sebastiaan Van Hoecke June 14, 2019

 I have the same problem, did you already found a proper fix @Frank Fu , what @csomme said is not clear to and doesn't work.

Frank Fu June 15, 2019

Not sure if it's a proper fix but I ended up implementing something like this as an Azure Function using C# and my CI/CD system just calls this.

https://gist.github.com/frankfuu/e1350ec8d18de284e4c76507ff0c2d6c

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events