I want to list all builds which have been executed on a TFS build agent during the last x days.
We are using TFS 15.117.27024.0. The build agents I would like to analyze are XAML build agents. I managed it to get a list of all build runs of a specific build definition (IBuildDetails), which unfortunately don't have the information on which agent the build was executed.
My approach so far is:
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(collectionURI);
tfs.EnsureAuthenticated();
IBuildServer buildServer = (IBuildServer)tfs.GetService(typeof(IBuildServer));
List<IBuildDefinition> definitions = buildServer.QueryBuildDefinitions(projectName);
IBuildDetail[] builds = definitions[0].QueryBuilds();
Console.WriteLine(builds[0].BuildAgentUri); // <- this does not exist
In the end I would like to have a list like this:
BuildAgent01
Build_20190410.4 (finished 4 min ago)
Build_20190410.3 (finished 3 min ago)
Build_20190410.2 (finished 2 min ago)
Build_20190410.1 (finished 1 min ago)
BuildAgent02
Build_20190410.8 (finished 8 min ago)
Build_20190410.7 (finished 7 min ago)
Build_20190410.6 (finished 6 min ago)
Build_20190410.5 (finished 5 min ago)
Does anyone know how to achieve this?