Is there a way to only get the builds that are waiting in queue for an available agent in a specific pool from the Azure DevOps rest API?
I currently have this endpoint that provides me with all the job requests that occurred in the pool:
https://dev.azure.com/{organization}/_apis/distributedtask/pools/{poolid}/jobrequests
I looked through the API documentation and am unable to find anything regarding agent pools.
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.If you don't want to iterate on all the builds (that make sense) you can retrieve the waiting builds in this way: