Question

Our server that has been used for our build drop locations is being retired. I know how to change the current build definition to use the new server, but how do you change the historical records for builds that have already completed? I want to be able to open past builds and click on 'Open Drop Folder' and be taken to the new server. We will manually copy the old builds to the new server.

Was it helpful?

Solution

The following sample seemed to work:

using System;
using System.Collections.Generic;
using Microsoft.TeamFoundation.Build.Client;
using Microsoft.TeamFoundation.Client;

namespace ChangeDropLocation
{
    class Program
    {
        static void Main()
        {
            TfsTeamProjectCollection teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://MyServer:8080/tfs/Collection"));
            var buildService = (IBuildServer)teamProjectCollection.GetService(typeof(IBuildServer));

            IBuildDetail buildDetail = buildService.GetBuild(new Uri("vstfs:///Build/Build/1506"));
            buildDetail.DropLocation ="\\somewhere";
            var buildDetails = new List<IBuildDetail>();
            buildDetails.Add(buildDetail);
            buildService.SaveBuilds(buildDetails.ToArray());
        }
    }
}

One thing that you should take into account is that you 'll probably be lacking the privilege to update build information. In my first attempt, although I am a Project admin, I got the following:

TF215106: Access denied. DOMAIN\username needs Update build information permissions for build definition myBuildDefinition in team project MyTeamProject to perform the action. For more information, contact the Team Foundation Server administrator.

In order to overcome this, set the right by right-clicking in TeamExplorer "Builds" & then select "Security...".

OTHER TIPS

I don't know of any tool to do this. Maybe there is a TFS powershell command, but short of that I think you could - AFTER TAKING PROPER PRECAUTIONS OF COURSE - update the SQL Db directly.

The mapping to the drop location is stored in the collection SQL Db in tbl_Build.

select [DropLocation],[DropLocationRoot],[LogLocation] from [tbl_Build]

I'm not sure if there are any implications on the warehouse though. Might want to check on that first.

I believe Microsoft generally recommends against manipulating SQL directly for stuff like this. You could use the TFS API instead which would be a relatively safer approach.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top