Skip to content

Instantly share code, notes, and snippets.

@ChrisRomp
Created September 2, 2022 18:37
Show Gist options
  • Save ChrisRomp/8ded852111929a42b9e4b564aa35ebfa to your computer and use it in GitHub Desktop.
Save ChrisRomp/8ded852111929a42b9e4b564aa35ebfa to your computer and use it in GitHub Desktop.
ADO Get Build Changes API workaround for 200 item limitation
@adoUser = {{$dotenv ADO_USER}}
@adoPat = {{$dotenv ADO_PAT}}
@adoOrg = YourAdoOrg
@adoProject = YourAdoProject
@buildId = 123
### Get Build Properties
# @name buildProps
GET https://{{adoUser}}:{{adoPat}}@dev.azure.com/{{adoOrg}}/{{adoProject}}/_apis/build/builds/{{buildId}}?api-version=7.1-preview.7
###
# Get History our build and one prior from our build's end time
# (including our build), using the finishTime of our build from
# the previous call and scoped to the same branch and pipeline
# @name history
GET https://{{adoUser}}:{{adoPat}}@dev.azure.com/{{adoOrg}}/{{adoProject}}/_apis/build/builds?api-version=7.1-preview.7&branchName={{buildProps.response.body.sourceBranch}}&$top=2&queryOrder=finishTimeDescending&maxTime={{buildProps.response.body.finishTime}}&definitions={{buildProps.response.body.definition.id}}
###
# Get Changes Between Builds using our buildId and the
# other id from the previous result's value[1] (second build)
@pageSize = 500
GET https://{{adoUser}}:{{adoPat}}@dev.azure.com/{{adoOrg}}/{{adoProject}}/_apis/build/changes?api-version=7.1-preview.2&fromBuildId={{history.response.body.value[1].id}}&toBuildId={{buildId}}&$top={{pageSize}}
@ChrisRomp
Copy link
Author

.env file example:

ADO_USER=username@domain.com
ADO_PAT=yourtoken

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment