Calendar

<<  mars 2010  >>
lumamejevesadi
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar
Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

(mars 10, 2008 08:43)

Few days ago, I was needing to be able to retrieve some informations about the builds we had launched. I was so needing to work with the TFS API.

To do this, you must have Visual Studio and a Team Explorer installed.

  1. Create a new application (a console application for example)
  2. Add a reference to the DLLs
    1. Microsoft.TeamFoundation.Build.Client
    2. Microsoft.TeamFoundation.Build.Common
    3. Microsoft.TeamFoundation.Client
    4. Microsoft.TeamFoundation.Common
You can find these DLLs in the folder "Program Files\Microsoft Visual Studio X.X\Common7\IDE\Private Assemblies
And after you can very simply interrogate the TFS API as for example :

string tfsUrl = "http://YourTFS:8080";

string teamProject = "Your Team Project Name";

string teamBuildType = "The name of your team build";

 

//Connect to the Team Foundation Server using the credentials

//of the currently logged person

TeamFoundationServer server = TeamFoundationServerFactory.GetServer(tfsUrl);

//Access the build service

BuildStore buildStore = server.GetService(typeof(BuildStore)) as BuildStore;

//and get the list of builds

BuildData[] buildDatas = buildStore.GetListOfBuilds(teamProject, teamBuildType);

 

//Iterate on all your builds

foreach ( BuildData buildData in buildDatas )

{

   PlatformFlavorData[] platforms = buildStore.GetPlatformFlavorsForBuild(buildData.BuildUri);

 

   // Iterate, for a specific build,

   // on all the build platform and flavor you have defined

   foreach ( var platformFlavor in platforms )

   {

      TestResultData[] testResults = buildStore.GetTestResultsForBuild(buildData.BuildUri, platformFlavor.PlatformName, platformFlavor.FlavorName);

 

      foreach ( TestResultData testResultData in testResults )

      {

         /* Here for each build platform and flavor

         * you are iterating on the test results

         */

      }

   }

}

Quite easy no ?

Juste one things to know : this code will work, whatever the version of your Visual Studio and TFS. But all the class you use here are deprecated under TFS 2008 (but will still work).

So how to do the same thing using the new TFS 2008's classes ? To be seen in a future post ! ;-)

Billets liés

Commentaires

mars 19. 2009 12:52

This shows how to do it the "new" way.

social.msdn.microsoft.com/.../

Scott

Ajouter un commentaire


 

  Country flag





Live preview

mars 12. 2010 23:23

Powered by BlogEngine.NET 1.2.0.0 | Theme by Pierre-Emmanuel Dautreppe