How to access the errors in TFSBuild 2010

I have a CI build configured in TFSBuild 2010 that creates a work item when the build fails. I would like to be able to put the build error messages into the work item description but I can't find any good way of accessing the error information.

Is there anyone who has solved this issue?

Upvotes: 2

Views: 582

Answers (2)

user2843997
user2843997

Reputation: 1

I concur with Duat Le, however, sometimes you have to force a save on the Information Nodes to get the data to show up.

Try this:

TfsTeamProjectCollection collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(teamProjectCollectionUrl);
IBuildServer buildServer = collection.GetService<IBuildServer>();
IBuildDetail build = buildServer.GetBuild(buildUri, new String[] {InformationTypes.BuildError, InformationTypes.BuildWarning }, QueryOptions.None);
build.Information.Save();
List<IBuildInformationNode> errorNodes = build.Information.GetNodesByType(InformationTypes.BuildError, false);

Upvotes: 0

Duat Le
Duat Le

Reputation: 3596

You can grab the build errors and/or warnings from the BuildInformation property of the IBuildDetail object that represents your build.

Some sample code for doing this can be found in this post.

TfsTeamProjectCollection collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(teamProjectCollectionUrl);
IBuildServer buildServer = collection.GetService<IBuildServer>();
IBuildDetail build = buildServer.GetBuild(buildUri, new String[] { InformationTypes.BuildError, InformationTypes.BuildWarning }, QueryOptions.None);

List<IBuildInformationNode> errorNodes = build.Information.GetNodesByType(InformationTypes.BuildError, false);

Upvotes: 4

Related Questions