Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,361,597
Community Members
 
Community Events
168
Community Groups

How do I get the list of files that were updated in a commit using bitbucket API 2.0?

I am working on creating a CI/CD pipeline. Once files are committed to my bitbucket repo, I want to be able to 

  1. Fetch the commit I want to (I can do that using the commits API with include/exclude).
  2. Get all files that were updated under that specific commit! (I"M LOOKING FOR A WAY TO FETCH THIS using API 2.0).

1 answer

0 votes
Mateus T Atlassian Team Aug 23, 2022

Hi @Saurabh Porwal,

Welcome to the Atlassian Community!

From the commits API, the results should also include a section with several links. Among those links, you have the option to grab the link for either the diff, or patch. The diff API should bring you the actual diff of that commit, allowing you to work out the files modified in this commit:

Curl -X GET "https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/diff/<commit>

In counterpart, the patch link should also contain a diff summary with all the files modified before showing the diff, so that could make it easier for you to parse the changes:

Curl -X GET "https://api.bitbucket.org/2.0/repositories/<workspace>/<repository>/patch/<commit>

Cheers,

Mateus T

Thanks @Mateus T both these APIs return the difference or patch and do have the file names but are in text format. I'm looking for an API response which could cleanly give me just filenames with path that have been updated preferably in JSON format so that is easier to parse and automate with any programming language.

Mateus T Atlassian Team Aug 23, 2022

@Saurabh Porwal,

Gotcha! I definitely see how the JSON format would make that easier.

For now, those endpoints are the best way to get those files in a specific commit. I did find an open feature request in our public bug tracker which you can check through the following here.

Our development team will give a first-hand update through that ticket if there's any progress made so I would suggest keeping a watch for it. Please note that all enhancements are implemented with this policy in mind.

Cheers,

Mateus T

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

3,496 views 3 10
Read article

Atlassian Community Events