有没有办法从Azure DevOps rest API中仅获取等待特定池可用代理的构建?目前我有这个端点,它为我提供了在池中发生的所有作业请求:https://dev.azure.com/{organization}/_apis/distributedtask/pools/{poolid}/jobrequests。我查看了API文档,但没有找到任何关于代理池的信息。
我也需要这个东西,但我使用的是Linux。在Linux上等价于@shayki-abramczyk的答案是:
jobRequests=$(curl -u peterjgrainger:${{ YOUR_DEVOPS_TOKEN }} https://dev.azure.com/{your_org}/_apis/distributedtask/pools/{your_pool}/jobrequests?api-version=6.0)
queuedJobs=$(echo $jobRequests | jq '.value | map(select(has("assignTime") | not)) | length')
runningJobs=$(echo $jobRequests | jq '.value | map(select(.result == null)) | length')
assignTime
属性,因此我搜索没有此属性的构建。#... Do the API call and get the repsone
$json = $repsone | ConvertFrom-Json
$json.value.ForEach
({
if(!$_.assignTime)
{
Write-Host "Build waiting for an agent:"
Write-Host Build Definition Name: $_.definition.name
Write-Host Build Id: $_.owner.id
Write-Host Queue Time $_.queueTime
# You can print more details about the build
}
})
# Printed on screen:
Build waiting for an agent:
Build Definition Name: GitSample-CI
Build Id: 59
Queue Time 2019-01-16T07:36:52.8666667Z
$waitingBuilds = $json.value | where {-not $_.assignTime}
# Then print the details