As Buck Hodges recently noted, some Team Build API documentation recently made it up onto MSDN. Unfortunately, most (maybe all? I haven’t been through it all) of the topics are skeletons, with no real content. I’ll be trying to remedy this by posting fleshed out documentation, sometimes even with examples…
Thus begins my 35 part series – better know a Proxy.
public BuildData GetBuildDetails (
This method can be used to obtain information about in-progress or completed builds, including their status, quality, and finish time. It takes a single parameter, buildUri, which is a string containing the full URI of a build – typically something like: “vstfs://Build/Build/09012006_010101_000001”. It returns a BuildData object, which contains various details about the build.
Of course, users do not typically know the Uri associated with an individual build, since it is not displayed in any of the standard Team Build GUI. To come up with a meaningful example, therefore, we’ll also have to cover the GetBuildUri method.
public string GetBuildUri (
This method can be used to obtain a build’s Uri given a Team Project and the build’s Number. These can readily be retrieved from the Team Build GUI, though the build number is typically displayed as the build name.
Here is an example console application that takes in a Team Foundation Server URL, a Team Project, and a Build Number and displays the corresponding build’s Uri, Status, Quality, and Finish Time.
static void Main(string args)
string tfsUrl = args;
string teamProject = args;
string buildNumber = args;
TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(tfsUrl);
BuildStore buildStore = (BuildStore)tfs.GetService(typeof(BuildStore));
string buildUri = buildStore.GetBuildUri(teamProject, buildNumber);
BuildData buildData = buildStore.GetBuildDetails(buildUri);
Console.WriteLine(“BuildUri = ” + buildData.BuildUri);
Console.WriteLine(“BuildStatus = ” + buildData.BuildStatus);
Console.WriteLine(“BuildQuality = ” + buildData.BuildQuality);
Console.WriteLine(“FinishTime = ” + buildData.FinishTime);
Of course, any real application along these lines would do some error checking, display a useful message when invalid arguments were supplied, etc.