tfs - 是否可以使用 TFS SDK 来创建、排队和跟踪构建?

标签 tfs sdk build-automation

我一直在谷歌搜索,找不到任何可靠的例子,或者它是否可以做到。我认为它可以。谁能指出我正确的方向?

到目前为止,我一直在查看 msdn 上的 TFS 命名空间文档。我的目标是能够从 Intranet Web 应用程序完全自动化和跟踪我们在 TFS 中的构建。

最佳答案

理查德为我指出了正确的方向,所以我将用我的发现来回答我自己的问题。
是的,您可以使用 TFS SDK 来创建、排队和跟踪构建。您需要的接口(interface)/类位于 Microsoft.TeamFoundation.Build.Client 命名空间中。 IBuildServer、IBuildDefinition 和 IBuildDetail 特别有用。
TFS 2010 更新:这是一个使用 TFS 2010 SDK 的示例程序,找到 here :

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

namespace ManageBuildTemplates
{
    class Program
    {
        static void Main(string[] args)
        {
            TfsTeamProjectCollection collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://jpricket-test:8080/tfs/collection0"));
            IBuildServer buildServer = collection.GetService<IBuildServer>();

            IBuildDefinition definition = buildServer.GetBuildDefinition("UnitTests", "Definition1");

            IBuildRequest request = definition.CreateBuildRequest();
            request.ProcessParameters = UpdateVerbosity(request.ProcessParameters, BuildVerbosity.Diagnostic);

            buildServer.QueueBuild(request);
        }

        private static string UpdateVerbosity(string processParameters, BuildVerbosity buildVerbosity)
        {
            IDictionary<String, Object> paramValues = WorkflowHelpers.DeserializeProcessParameters(processParameters);
            paramValues[ProcessParameterMetadata.StandardParameterNames.Verbosity] = buildVerbosity;
            return WorkflowHelpers.SerializeProcessParameters(paramValues);
        }
    }
}

关于tfs - 是否可以使用 TFS SDK 来创建、排队和跟踪构建?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/611485/

相关文章:

java - 从 TFS 2015 中的发布定义执行 Selenium java 脚本

android - 在重叠 View 的情况下控制触摸事件传播

version-control - 互斥团队城市 build 触发双方开火

build-automation - 无法在自定义构建过程模板中删除 TFS2010 的自定义工作流事件

c++ - 使用TFS生成版本头文件

tfs - 如何删除项目 - Visual Studio Team Services

tfs - TFS 2010 构建质量更改后发布到 FTP

ios - Testflight 在 Mac OS X 桌面应用程序中找不到 SDK?

java - SDK项目的结构和Gradle构建?

java - Maven:远程运行单元测试