使用TFS 2015在队列构建时指定代理 [英] Specifying agent at queue build time with TFS 2015
问题描述
是否可以配置内部版本,以便您在手动排队内部版本时设置希望在哪个代理上运行?
Is it possible to configure a build so you can set which agent you want it to run on when you manually queue a build?
推荐答案
您的方案是否有特殊之处?
Do you have any special in your scenario?
通常,在VSTS中,您可以在手动排队构建时选择要直接运行的代理(托管):
Generally, in VSTS you can select which agent (Hosted) you want to run directly when you manually queue a build:
更新:
如果您使用本地TFS(在您的方案中为TFS 2015)或VSTS专用代理.然后,您可以在对构建进行排队时设置需求.
If you are using on-premise TFS (TFS 2015 in your scenario) or Private agent for VSTS. Then you can set Demands when you queue a build.
您还可以使用REST API将构建排队,并指定与特定代理匹配的需求:
You can also queue build with the REST API and specify the demands which match the specific agent:
例如:
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)}
这篇关于使用TFS 2015在队列构建时指定代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!