通过PowerShell触发带有架子集的TFS vNext Gated构建

时间:2018-12-10 19:43:36

标签: powershell tfs azure-devops azure-devops-rest-api

我正在尝试使用我选择的架子来触发TFS Gated vNext构建。下面的代码成功触发了门控构建,但未在货架集中传递。

我正在运行TFS 2017更新3。

[string]$TFSuser = "UserName"
[string]$TFSUserPAT = "PAT"

$body = '
{ 
        "definition": {
            "id": "987",
            "sourceBranch":"Gated_2018-12-01_10.42.36.6232",
            "reason" : "checkInShelveset"
        } 
}
'
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $TFSuser,$TFSUserPAT)))

$Uri = "https://TFSAddress.com/tfs/DefaultCollection/TN/_apis/build/builds?api-version=2.0"
$buildresponse = Invoke-RestMethod -Method Post -UseDefaultCredentials -ContentType application/json -Uri $Uri -Body $body -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
write-host $buildresponse

0 个答案:

没有答案