我正在使用TFS 2017设置构建/发布环境。
我将Build设置为在每次提交后自动运行,并且当我们准备发布应用程序的版本时,将手动创建一个Release,然后将其部署到各种环境中。
我们想在git仓库中标记已发布的版本,以便轻松知道哪个git版本对应于二进制文件。Build定义中的“ Label Source”设置允许在构建时标记git版本,但是由于我们基于每次提交都会生成很多我们不关心的标记(因为它们不会被部署到任何地方,发布)。
如何设置TFS,以便在创建Release(或可能将其部署到环境)时,在Git存储库中的相应提交上创建标签?
您可以使用REST API添加标签:
POST https://{instance}/DefaultCollection/_apis/git/repositories/{repository}/refs?api-version={version}
[
{
"name": {string},
"oldObjectId": {string}, (The current commit id the ref is at. 0000000000000000000000000000000000000000 when creating a new ref.)
"newObjectId": {string}
}
]
通过PowerShell调用Rest API:
$result = Invoke-RestMethod -Uri $uri -Method Get -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
有关更多信息,您可以参考使用PowerShell调用VSTS API(适用于tfs 2017)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句