3

I want to Access Information of Builds of Team Projects to use them in other Applications of our Company. What I need is requesting all Builds for a Team Projekt. I need Information like: - the UNC Path the Outlut was copied to - the Name - Date of Build - who started ór triggered the Build (if possible)

I did not find any discription how the Access Information on TFS via Web Services. What I learned is that TFS has a Service Interface.

I hope anyone can give me a litte hint how to reach my goal. If anyone has some sample code I surely would be delighted :-)

sebastianmehler
  • 1,033
  • 1
  • 11
  • 23

2 Answers2

2

Would something like that be helpful:

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://tfsURI"));
            var buildService = (IBuildServer)teamProjectCollection.GetService(typeof(IBuildServer));

            IBuildDefinition buildDefinition = buildService.GetBuildDefinition("TeamProjectName", "BuildDefinitionName");
            IBuildDetail[] buildDetails = buildService.QueryBuilds(buildDefinition);

            foreach (var buildDetail in buildDetails)
            {
                IBuildInformation buildInformation = buildDetail.Information;
                Console.Write(buildDetail.BuildNumber+"\t");
                Console.Write(buildDefinition.Name+"\t");
                Console.Write(buildDetail.Status+"\t");
                Console.Write(buildDetail.StartTime+"\t");
                Console.WriteLine((buildDetail.FinishTime - buildDetail.StartTime).Minutes);
            }
        }
    }
}

This is just a standard usage of the TFS-SDK, and I think it provides with the info you 're looking for.

pantelif
  • 8,524
  • 2
  • 33
  • 48
  • Thanks for this great exaple. I do not get it running because I allways get an "HTTP 404 Page not Found" Error back. my Calls looks like that: TfsTeamProjectCollection teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://MyTfsServerHostName:8080/tfs")); This is the URL I configures Visual Studio with... I also tried http://MyTfsServerHostName as well with an Error 501 – sebastianmehler Jun 18 '12 at 08:59
  • 3
    In Team Explorer, right-click on the master-node of the Team Collection and select Properties. Use what you see in the `Url` property (something like `http://TFSName:8080/tfs/CollectionName`) – pantelif Jun 18 '12 at 09:07
1

I suggest using wrapper for the wrapper to access to TFS since it's much easier and may be enough for what you need.

If not, I suggest using TFS SDK.

If you still want to go lower, then please read this SO.

Community
  • 1
  • 1
Ray Cheng
  • 12,230
  • 14
  • 74
  • 137