【问题标题】:TFS - Triggering two builds with CITFS - 使用 CI 触发两个构建
【发布时间】:2020-02-26 01:49:49
【问题描述】:

目前,我有三个具有相应构建的解决方案,它们产生三个工件:

CommonSolution -> BuildA -> Common.dll (output drops into a nuget feed)
ProgramSolution -> BuildB -> Program.exe
ServiceSolution -> BuildC -> Service.svc

Program.exe 和 Service.svc 都通过 nuget 提要使用 Common.dll,并且应该是完全相同的版本。

目前所有构建都是隔离的,因此构建了 CommonSolution。然后在 Program/Service 中手动更新 Common nuget,然后构建它们。

在TFS中,有没有什么办法,如果触发了BuildB,会先自动触发BuildA,然后在BuildB和BuildC中更新消耗Common nuget,触发两次build?

或者还有其他更适合的设置吗?

【问题讨论】:

  • 你使用的是什么 tfs 版本?
  • @Jayendran 版本 15.117.26714.0 即 TFS 2017

标签: tfs continuous-integration


【解决方案1】:

编辑构建配置时,转到触发器选项卡并启用持续集成。您可以在此处定义路径过滤器并指定解决方案文件夹的路径,因此只有在将更改签入到该不同路径时才会触发构建。

在您的情况下,只有 CommonSolution 更改,dll 将被更新。然后只需要链接构建 B 和构建 C。

对于最新版本的 TFS-Azure DevOps Server 2019,我们确实有一个内置功能:Build completion triggers

大型产品有多个依赖于每个组件的组件 其他。这些组件通常是独立构建的。当一个 上游组件(例如库)更改,下游 必须重建和重新验证依赖项。

在这样的情况下 这些,添加一个构建完成触发器来运行你的构建 成功完成触发构建。您可以选择任何 同一项目中的其他构建。

对于 TFS 版本 2018 及之前的版本,有两种方法可以在当前构建中运行另一个构建。

选项 1:将当前构建定义中的 PowerShell 任务添加到 queue another build by REST API

假设另一个构建 id 是 5,那么您可以使用脚本添加 PowerShell 任务:

$body = @{
definition = @{
id = 5    
}
}
$Uri = "http://account.visualstudio.com/DefaultCollection/project/_apis/build/builds?api-version=2.0"
$buildresponse = Invoke-RestMethod -Method Post -UseDefaultCredentials -ContentType application/json -Uri $Uri -Body (ConvertTo-Json $body)  

选项 2:在 Marketplace 中安装相关扩展 您可以为本地 TFS 服务器安装一些扩展,然后您可以将任务添加到另一个构建队列中。如Queue Build(s) TaskTrigger New BuildQueue New Build

is there any way such that if BuildB is trigged, it automatically triggers BuildA first所以,你可以在运行Build B的过程中增加一个触发Build A的步骤。

【讨论】:

    猜你喜欢
    • 2018-01-06
    • 1970-01-01
    • 1970-01-01
    • 2017-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多