2017-03-16 30 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 –

相关问题