2015-08-28 128 views

回答

4

这个问题不时出现。官方文档literally say "not yet"(参见最后一个Q &条目)。还有an ancient suggestion on UserVoice,从今年3月份开始计划进入状态。这非常有希望,并且让我希望这将在vNext构建系统中首先实现。

+0

TFS vNext路线图出来Q2 2016 ...功能仍然没有出现在那里 – felickz

1

如果这个答案只适用:

  • 您使用的Git与TFS2015
  • 你想下superprojects
  • 所有的构建问题链,建立子模块是持续集成构建。

如果是这样的话,那么你就可以“链构建”以欺骗(我的作品):

  1. 在每个子模块中添加一个批处理文件(致力于源控制),该脚本将此子模块的分支(即正在构建的)上的最新提交重新添加到其超级项目中。 这样做的目的(副作用)是在超级项目的状态中引入“更改”,足以触发该超级项目上的CI构建。
  2. 在每个子模块的构建定义中,添加一个“批处理脚本”vNext步骤。
  3. 指出相应子模块的批处理文件的步骤。
  4. 此构建步骤需要成为构建的最后一步,以确保它只在构建成功时执行,然后执行其“mod”并触发超级项目上的CI构建。

为了让您开始,请参阅下面的示例脚本。这个特定的脚本只适用于在文件系统中彼此“嵌套”的子模块 - matreshka-style。否则,每个子模块都需要一个自定义脚本。

请注意,它包含了一些我遇到的一些问题的解决办法,让我做它我需要做的事情(例如,在将更改推送到服务器之前,在本地克隆/初始化子模块,然后整理文件)。

让我知道是否需要更多意见。

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% 
3

我实现了“链”通过创建一个自定义BuildTask基本上只是让到TFS REST API适当的呼叫建立。它允许我定义一个我想触发的构建定义(按名称),并在顶部添加一些条件(例如,检查这个定义的构建是否已经排队或检查某个定义的最后构建是否成功)。

如果有兴趣,我上传了源代码到github

使用TFX您可以将任务上传到您的TFS see details here
总之只是抓住从GitHub上的文件,通过节点安装TFX和运行

tfx build tasks upload --task-path ./triggerbuildtask 

之后,你可以选择触发新的建设任务和配置它: enter image description here

希望这可能会帮助一些人试图实现相同的事情。

编辑
我打包的任务,并将其发布在Marketplace上,所以它可以很容易地使用该任务在您的环境:
Trigger Build Task

+0

使用休息API目前听起来正确的方向来解决这个问题。 – cli