2017-03-16 49 views
1

我有一個從2015年vNext團隊構建調用的PowerShell腳本(Start-TargetBuild.ps1)。該腳本使用REST接口啓動另一個團隊構建。該腳本工作正常,除非我試圖將shelveset添加到初始構建。在這種情況下,我收到以下錯誤:如何使用REST API在TFS 2015中使用shelveset觸發構建

Start-TargetBuild : Error in REST API call! 
At \\chdfileserver01\IT\PowerShell_Library\TeamBuild-Launch.ps1:426 char:2 
+ Start-TargetBuild 
+ ~~~~~~~~~~~~~~~~~ 
+ CategoryInfo : InvalidOperation: (:) [Write-Error], WriteErrorException 
+ FullyQualifiedErrorId : {"$id":"1","innerException":null,"message":"Value cannot be null.\r\nParameter name: build","typeName":"System.ArgumentNullException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561 
934e089","typeKey":"ArgumentNullException","errorCode":0,"eventId":0}.ErrorDetails.Message,Start-TargetBuild 

我在想什麼?

謝謝。

回答

1

要使用shelveset觸發構建,應在REST API正文中使用sourceBranch參數。

sourceBranch: "The shelveset name","The shelveset owner" 
+0

謝謝帕特里克。這導致了下一個問題 - 如何在團隊構建中從PowerShell訪問shelveset名稱/所有者?我可以在「獲取源」步驟中看到擱架未放置到構建工作區中的哪一步。所以,顯然這些信息會傳遞給構建。 –

+0

@ LS-1要獲得貨架信息,您可以使用[獲取貨架列表](https://www.visualstudio.com/en-us/docs/integrate/api/tfvc/shelvesets)rest api,它將返回shelvesets的詳細信息。對於店主,建議你使用'uniqueName:「[email protected]」' –

+2

不要介意我以前的評論。我看到shelveset信息在傳遞給團隊構建的環境變量中; $ env:BUILD_SOURCETFVCSHELVESET –