There is no out of the box such API, but we can use the regular API and filter the results.
For example, I use the API you provided and I got all the builds in the pool, then, I filtered the results with PowerShell to get only the builds that waiting for an available agent.
How do I know who waiting? in the JSON result, to each build have some properties, if the build started to run on an agent he got a property assignTime
, so I search builds without this property.
#... 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
If you don't want to iterate on all the builds (that make sense) you can retrieve the waiting builds in this way:
$waitingBuilds = $json.value | where {-not $_.assignTime}
# Then print the details