Azure Devops Rest API - Find out Queue Jobs on a specific Agent Pool
Asked Answered
R

2

7

From the Azure-DevOps Rest API documentation https://learn.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.

Rowland answered 2/7, 2019 at 9:31 Comment(0)
P
7

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" })
Publisher answered 2/7, 2019 at 10:59 Comment(0)
C
3

The URL from this answer does not work with the current API version 7.1.

But in a GitHub issue I found another URL variant of this undocumented API which still worked in my tests.

https://{organization}.visualstudio.com/_apis/distributedtask/pools/{poolid}/jobrequests

You can then filter items which have assignTime not set. These are the pending jobs.

Coltish answered 22/2, 2023 at 12:56 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.