How to get the oldest commit of a specific BuildId via [Get Build Changes] API

Amber Liu 1 Reputation point
2021-10-14T22:19:16.857+00:00

Tried to get the oldest commit from a specific build.

https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/changes?continuationToken={continuationToken}&api-version=6.0

The [Get Build Changes] API above seems to be the proper API to be used. However, it defaults to return the latest 50 commits of the build.

This made me have to send more API requests with the response header [x-microsoft-continuation] for next 50 commits until the last page to get the oldest commit of the build, which is not that efficient for my use case.

Would you please suggest if there is any easier way (less API calls) that I could use to get the oldest commit of a specific build?

Here are also one more questions : Is there any easier way to know the total number of commits for a specific build?

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,773 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MayankBargali-MSFT 67,991 Reputation points
    2021-10-18T03:13:23.343+00:00

    Hi @Amber Liu

    Welcome to Microsoft Q&A! Thanks for posting the question.

    DevOps is currently not supported in the Q&A forums, the supported products are listed over here https://learn.microsoft.com/en-us/answers/products (more to be added later on).

    You can ask the experts in the dedicated forum over here:
    https://stackoverflow.com/questions/tagged/devops
    https://developercommunity.visualstudio.com/spaces/21/index.html

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

    0 comments No comments