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

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

Saurabh Porwal August 17, 2022

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
Atlassian Team members are employees working across the company in a wide variety of roles.
August 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

Saurabh Porwal August 23, 2022

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
Atlassian Team members are employees working across the company in a wide variety of roles.
August 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
AUG Leaders

Atlassian Community Events