My initial intention was to tell you the TFS OLAP Cube and describe how you could get what came after. Then I realized that the cube does not contain the information that the agent built that Build.
Then I thought it would be easy to write a small TFS console application that prints the information you are after:
using System; using Microsoft.TeamFoundation.Build.Client; using Microsoft.TeamFoundation.Client; namespace BuildDetails { class Program { static void Main() { TfsTeamProjectCollection teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://TFS:8080/tfs/CoLLeCtIoNNaMe")); var buildService = (IBuildServer)teamProjectCollection.GetService(typeof(IBuildServer)); IBuildDefinition buildDefinition = buildService.GetBuildDefinition("TeamProjectName", "BuildDefinitionName"); IBuildDetail[] buildDetails = buildService.QueryBuilds(buildDefinition); foreach (var buildDetail in buildDetails) { Console.Write(buildDetail.BuildNumber+"\t"); Console.Write(buildDefinition.Name+"\t"); Console.Write(buildDetail.BuildAgent.Name+"\t"); Console.Write(buildDetail.Status+"\t"); Console.Write(buildDetail.StartTime+"\t"); Console.WriteLine((buildDetail.FinishTime - buildDetail.StartTime).Minutes); } } } }
This will not compile since
I ended up in IBuildInformationNode[]
and got the build agent as follows:
IBuildInformation buildInformation = buildDetail.Information; IBuildInformationNode[] buildInformationNodes = buildInformation.Nodes; string agentName; try { agentName = buildInformationNodes[0].Children.Nodes[3].Fields["ReservedAgentName"]; } catch { agentName = "Couldn't determine BuildAgent"; } Console.Write(agentName + "\t");
Try-catch is required, so you can deal with assemblies that did not run / stop before selecting an agent.
If you use this last part as a replacement for the failed Console.Write(buildDetail.BuildAgent.Name+"\t");
, you should end up with a console application whose output can be transferred to a * .CSV file and then imported into Excel.
pantelif
source share