Share via


Creating Skeleton Builds in Teambuild to Publish Test Results

There are several requests on how to publish test results to a TFS server without really creating a build. The build entry is a prerequisite for publishing test results, so you will need to create one and also create an associated project configuration against which the test results will be published. You can use TeamBuild web services to do this. Here is a sample:

The following sample creates a build named ‘SkeletonBuild001’ under TeamProject ‘MyTeamProject’ and Debug/X86 configuration which can be used to publish results against. Make sure that the drop location exists before publishing test results.

using Microsoft.TeamFoundation.Client;

using Microsoft.TeamFoundation.Build.Proxy;

using System;

// This sample references Microsoft.TeamFoundation.Build.Common.dll and Microsoft.TeamFoundation.Client.dll

namespace TeamBuildSamples

{

    class Program

    {

        static void Main(string[] args)

        {

            //Construct a buildstore object connecting to MyTFSServer

            BuildStore bStore = (BuildStore)(new TeamFoundationServer("https://MyTFSServer:8080").GetService(typeof(BuildStore)));

            //Create a build entry

           

            BuildData bd = new BuildData();

    //Fill in mandatory information for BuildData object

            bd.BuildNumber = "SkeletonBuild001";

            bd.BuildType = "DummyBuildType";

            bd.TeamProject = "MyTeamProject";

            // Make sure that this drop location exists, otherwise test publish will fail

            bd.DropLocation = @"\\vse1010\drops\SkeletonBuild001";

            bd.BuildMachine = "NoBuildMachine";

            bd.RequestedBy = Environment.UserName;

            bd.BuildStatus = "Successfully Completed";

            bd.BuildQuality = "Used for Publishing Test Results";

            // Add build entry to TeamBuild DB

            bStore.AddBuild("MyTeamProject", bd);

            string buildUri = bStore.GetBuildUri("MyTeamProject", "SkeletonBuild001");

            //Create platform/flavor information against which the test results will be published

            ProjectData pd = new ProjectData();

            //Fill in mandatory information for ProjectData object

            pd.FlavourName = "Debug";

            pd.PlatformName = "x86";

            pd.ProjectFile = "Dummy.sln";

            //Add project data entry for this build.

            bStore.AddProjectDetailsForBuild(buildUri, pd);

        }

    }

}

Namaste!