4
votes

From the Azure-DevOps Rest API documentation https://docs.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-5.1 there is no clear way to query for the Jobs running on a specific Agent Pool.

Went through the different API calls plus fiddler.

curl -u X:X https://dev.azure.com/{organization}/_apis/distributedtask/pools/{poolId}/agents?api-version=5.1-preview.1 --> gets the running agents on a specific agent pool

What is the REST API call to get jobs on the queue on a specific Agent Pool? I expected a JSON output with the jobs running on a specific Agent Pool.

1

1 Answers

6
votes

You can get all the jobs requests in specific pool with this Rest API:

https://dev.azure.com/{organiztion}/_apis/distributedtask/pools/{poolId}/jobrequests

Now you can filter only the running job, how? to the running job there is no result property, so in PowerShell you can do sometnig like this:

$json = $jobs | ConvertFrom-Json
$runningJobs = $json.Where({ $_.PSobject.Properties.name -notcontains "result" })