是否可以配置构建,以便在手动排队构建时设置要运行的代理?
答案 0 :(得分:1)
你的场景有什么特别之处吗?
通常,在VSTS中,您可以在手动排队构建时选择要直接运行的代理(托管):
<强>更新强>
如果您使用的是内部部署TFS(在您的方案中为TFS 2015)或VSTS的私有代理。然后,您可以在对构建进行排队时设置需求。
您还可以使用REST API对构建进行排队,并指定与特定代理匹配的需求:
e.g:
Param(
[string]$collectionurl = "http://server:8080/tfs/DefaultCollection/",
[string]$projectName = "0323ScrumTFVC",
[string]$keepForever = "true",
[string]$BuildDefinitionId = "1",
[string]$user = "username",
[string]$token = "password"
)
# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))
function CreateJsonBody
{
$value = @"
{
"definition": {
"id": $BuildDefinitionId
},
"sourceBranch": "$/0323ScrumTFVC",
"demands":["Agent.Name -equals AgentNameHere"]
}
}
"@
return $value
}
$json = CreateJsonBody
$uri = "$($collectionurl)/$($projectName)/_apis/build/builds?api-version=2.0"
$result = Invoke-RestMethod -Uri $uri -Method Post -Body $json -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
答案 1 :(得分:1)