2015-08-28 114 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