Reputation: 2043
What is the suggested way to find / display the average build and release (rather deployment) times within VSTS.
The reason for this is to be able to find out which ones are taking longer than I'd like so that I can cut down the time taken. I don't want to have to manually click into each and every build and deployment to have to find the information.
Other than writing a script to hit the API I am not sure what other options I have available to me.
Upvotes: 2
Views: 1196
Reputation: 38106
To get last n builds from a build definition, you can follow below steps:
Get the buildId of the n’s builds separately
You can use List builds REST API to get the n’s builds:
GET https://{account}.visualstudio.com/{project}/_apis/build/builds?definitions={definitionId}&$top={n}&api-version=4.1
Get the Timeline for each build
To get the timeline for a build, you can use Build Timeline REST API:
GET https://{account}.visualstudio.com/{project}/_apis/build/builds/{buildId}/timeline?api-version=4.1
For the build time of a build, it’s (last task finishTime) – (first task startTime)
. And you can get the total build time of the n’s builds by sum each build time.
Calculate the average build time
After get the total build time, then you can get the average build time for the n’s builds.
For average release time you can use the similat method.
Upvotes: 2