如何使用TFS实现构建管道

时间:2022-05-27 08:08:42

I try to implement a build pipeline using TFS.

我尝试使用TFS实现构建管道。

We already have TFS building our projects after each commit. But the build take too long so we would like to split the build into two stages. Continuous integration literature suggest this technique.

每次提交后,我们已经有TFS构建我们的项目。但构建时间太长,所以我们希望将构建分为两个阶段。持续整合文献提出了这种技术。

So what I am looking for is something to do the following.

所以我正在寻找的是要做的事情。

  • Developer checks in his source code.
  • 开发人员检查他的源代码。

  • TFS automatically triggers a build to compile the code and run some basic tests (we already have that). The developer gets quick feedback that his changes did not break something obvious.
  • TFS自动触发构建以编译代码并运行一些基本测试(我们已经有了)。开发人员得到快速的反馈,他的更改没有打破明显的东西。

  • Next if the build succeeded a new TFS task/build is triggered which takes the artifacts from the previous stage and runs some more time consuming tests.
  • 接下来,如果构建成功,则会触发新的TFS任务/构建,该任务/构建将从前一阶段获取工件并运行一些更耗时的测试。

Any ideas on how to implement this?

有关如何实现这一点的任何想法?

3 个解决方案

#1


1) Write a service that listens for the BuildCompleted event. IIS webservice sample code. Self-hosted WCF sample code. In your event handler, either call the TFS Build API to kick off a separate build type that defines additional tasks, or simply execute custom code directly from here.

1)编写一个侦听BuildCompleted事件的服务。 IIS webservice示例代码。自托管WCF示例代码。在您的事件处理程序中,要么调用TFS Build API来启动定义其他任务的单独构建类型,要么直接从此处执行自定义代码。

2) Register your service with TFS, adding a server side filter on successful builds.

2)使用TFS注册您的服务,在成功构建时添加服务器端过滤器。

#2


At the moment we're doing this using the <AfterEndToEndIteration> target in MSBuild, and <Exec>ing TfsBuild.exe.

目前我们正在使用MSBuild中的 目标和 ing TfsBuild.exe执行此操作。

<Target Name="AfterEndToEndIteration">
  <PropertyGroup>
    <TfsBuildExecutable>C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\TfsBuild.exe</TfsBuildExecutable>
    <CommandToTriggerNextStage>&quot;$(TfsBuildExecutable)&quot; start /server:$(TeamFoundationServerUrl) /buildDefinition:&quot;Project\Next Stage&quot; /queue</CommandToTriggerNextStage>
  </PropertyGroup>

  <Exec Condition=" '$(Status)'!='Failed' "
        Command="$(CommandToTriggerNextStage)" />    
</Target>

#3


You could have your intermediary, or minor builds check-in the resulting assemblies into source-control. That way you can have the other build use the already compiled DLL's to package and build the second part of the system.

您可以让您的中间件或次要构建签入生成的程序集到源代码控制中。这样你就可以让另一个构建使用已编译的DLL来打包和构建系统的第二部分。

You could have the "bigger" assembling build listen to check-ins from the library builds and assemble the builds dependant on that one.

您可以让“更大”的组装构建从库构建中收听签到,并根据该构建组装构建。

Sure you get to check-in binary code, but unless your doing something strange you should have enough harddrive space.

当然你得到签入二进制代码,但除非你做一些奇怪的事情,否则你应该有足够的硬盘空间。

#1


1) Write a service that listens for the BuildCompleted event. IIS webservice sample code. Self-hosted WCF sample code. In your event handler, either call the TFS Build API to kick off a separate build type that defines additional tasks, or simply execute custom code directly from here.

1)编写一个侦听BuildCompleted事件的服务。 IIS webservice示例代码。自托管WCF示例代码。在您的事件处理程序中,要么调用TFS Build API来启动定义其他任务的单独构建类型,要么直接从此处执行自定义代码。

2) Register your service with TFS, adding a server side filter on successful builds.

2)使用TFS注册您的服务,在成功构建时添加服务器端过滤器。

#2


At the moment we're doing this using the <AfterEndToEndIteration> target in MSBuild, and <Exec>ing TfsBuild.exe.

目前我们正在使用MSBuild中的 目标和 ing TfsBuild.exe执行此操作。

<Target Name="AfterEndToEndIteration">
  <PropertyGroup>
    <TfsBuildExecutable>C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\TfsBuild.exe</TfsBuildExecutable>
    <CommandToTriggerNextStage>&quot;$(TfsBuildExecutable)&quot; start /server:$(TeamFoundationServerUrl) /buildDefinition:&quot;Project\Next Stage&quot; /queue</CommandToTriggerNextStage>
  </PropertyGroup>

  <Exec Condition=" '$(Status)'!='Failed' "
        Command="$(CommandToTriggerNextStage)" />    
</Target>

#3


You could have your intermediary, or minor builds check-in the resulting assemblies into source-control. That way you can have the other build use the already compiled DLL's to package and build the second part of the system.

您可以让您的中间件或次要构建签入生成的程序集到源代码控制中。这样你就可以让另一个构建使用已编译的DLL来打包和构建系统的第二部分。

You could have the "bigger" assembling build listen to check-ins from the library builds and assemble the builds dependant on that one.

您可以让“更大”的组装构建从库构建中收听签到,并根据该构建组装构建。

Sure you get to check-in binary code, but unless your doing something strange you should have enough harddrive space.

当然你得到签入二进制代码,但除非你做一些奇怪的事情,否则你应该有足够的硬盘空间。