开发者

TFS 2010 Issue with tracking Changesets in Builds that are a result of Gated Checkins

In order to retrieve the information which Changeset was included in which Build, we use "Label Sidekick" of Team Foundation Sidekicks, where we place the Label of the Build & expect to find the newly built Changeset.

Our development process in TFS 2010 is making use of 'Gated' checkins, so we are faced with the situation that the latest checkins are not presented in Sidekicks (we actually receive the changeset of the previous build). This is explainable, since at the time the labeling takes place, the latest changes have not yet been committed.

The BuildLog does report 开发者_Python百科the associated Changeset correctly.

I 've made several experiments in our Build Process Template but can't seem to get what we need. Placing, for example, the Labeling activity out of the "Run On Agent" scope, lead me to a build that fails at the very start with an "Object reference not set to an instance of an object." (I suppose this is related with fact I had to widen the scope for 'Label' & 'Workspace' variables to get the second part running).

The 'before' state of the build process template for this attempt is here (this works), the 'after' state ("Object ref not set..") is here.

So, to summarize, two different types of input could help me out:

How should I change our build process template so that the labeling happens after the Gated checkins have been committed? (-- This would rationalize the display in Sidekicks)

or

How can I programmatically retrieve the associated Changeset of each Build? (-- This would enable me to write a small app that could obsolete the Sidekicks angle)


You can use the TFS API to get this done.

        public static void GetBuild()
    {
        var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://tfsdevlonuk:8080/tfs/gazprom.mt"), new UICredentialsProvider());
        tfs.EnsureAuthenticated();
        var buildServer = tfs.GetService<IBuildServer>();

        // Get Project Name
        var versionControl = tfs.GetService<VersionControlServer>();
        var teamProjects = versionControl.GetAllTeamProjects(true);

        // Get Builds for a team project
        var buildDetails = buildServer.QueryBuilds(teamProjects[0].Name);

        // For each build
        foreach (IBuildDetail buildDetail in buildDetails)
        {
            // Get the build details
            var buildInfor = buildDetail.Information;

            // More build infor like shelveset, etc
            Debug.Write(buildDetail.LabelName + buildDetail.ShelvesetName);

        }

The above code will help you get the build details programatically. I have some blog posts on how to connect to tfs programmatically and use the tfs api. http://geekswithblogs.net/TarunArora/archive/2011/06/18/tfs-2010-sdk-connecting-to-tfs-2010-programmaticallyndashpart-1.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜