【发布时间】:2015-11-23 02:09:15
【问题描述】:
在 TFS 2015 中有没有办法进行两个构建,以便在第一个构建完成(成功)时触发第二个构建? aresolutions 用于旧的基于 XAML 的构建系统,但没有用于新的基于脚本的系统,这是我正在使用的。
【问题讨论】:
在 TFS 2015 中有没有办法进行两个构建,以便在第一个构建完成(成功)时触发第二个构建? aresolutions 用于旧的基于 XAML 的构建系统,但没有用于新的基于脚本的系统,这是我正在使用的。
【问题讨论】:
我通过创建一个自定义 BuildTask 来实现构建的“链接”,它基本上只是对 TFS REST Api 进行适当的调用。然后,它允许我定义一个我想要触发的构建定义(按名称),并在顶部添加一些条件(例如检查是否有此定义的构建已经排队或检查某个定义的最后构建是否成功)。
如果有兴趣,我把源代码上传到github。
使用 tfx,您可以将任务上传到您的 TFS see details here
简而言之,只需从 github 获取文件,通过节点安装 tfx 并运行
tfx build tasks upload --task-path ./triggerbuildtask
在此之后,您可以选择 Trigger new Build Task 并对其进行配置:
希望这可以帮助一些尝试实现相同目标的人。
编辑
我将任务打包并发布在 Marketplace 上,以便在您的环境中轻松使用任务:
Trigger Build Task
【讨论】:
这个问题时不时出现。官方文档literally say "not yet"(见最后一个问答条目)。还有an ancient suggestion on UserVoice,从今年3月开始就处于Planned状态。这很有希望,让我希望这将首先在 vNext 构建系统中实现。
【讨论】:
此答案仅适用于:
如果是这种情况,那么你可以通过作弊来“建立链”(对我有用):
要开始使用,请参阅下面的示例脚本。此特定脚本仅适用于文件系统中相互“嵌套”的子模块 - matreshka 样式。否则,每个子模块都需要一个自定义脚本。
请注意,它包含一些解决方法,用于解决我遇到的一些问题,使其完成我需要它做的事情(即在将更改推送到服务器之前,在我的机器上本地克隆/初始化子模块,然后整理文件)。
如果需要更多 cmets,请告诉我。
REM Name of your submodule repository...
set subRepo=%1
REM Name of your superproject (with respect to this submodule) repository...
set superRepo=%2
REM Name of the folder into which the content of submodule will be cloned ...
REM Without this alias the folder will be called the same as the repo you are cloning.
set subAlias=%3
REM Branch to link to, given by $(Build.SourceBranchName) in the parameters you pass
REM to the "Run Batch" build step (that will be executing this batch file)...
set branch=%4
REM Repositories' URLs - ONLY SAMPLE URLS - Please use your own !!!
set superUrl="http://<YourTfsServerName>:8080/tfs/DefaultCollection/_git/%superRepo%"
set subUrl="http://<YourTfsServerName>:8080/tfs/DefaultCollection/<YourSuperProjectName>/_git/%subRepo%"
REM Get the latest commit on current branch...
git log -1 --pretty=format:"%%h" > Output.txt
for /f %%i in (Output.txt) do set commit=%%i
IF NOT EXIST %superRepo% GOTO NOWINDIR
cd %superRepo%
REM Handle the .git directory specifically...
cd .git
for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
cd ..
rmdir .git
REM Remove the rest of files and folders...
for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
cd ..
rmdir %superRepo%
:NOWINDIR
REM Clone superproject and checkout the required branch *********************************************
git clone %superUrl%
cd %superRepo%
git checkout %branch%
git pull origin %branch%
git submodule update --init --recursive -f
cd %subAlias%
git checkout %commit%
cd ..
git add %subAlias%
git commit %subAlias% -m "Updated %subRepo% reference to %commit% as %subAlias%"
git push origin %branch%
【讨论】: