Reputation: 25
I want to create some reporting around pipelines that use MS hosted public agents to run jobs.
This info is available via the UI (Org Settings > Agent Pools > Azure Pipelines) - but not via the REST API it would seem.
I can return all Agent Pools:
GET https://dev.azure.com/{organization}/_apis/distributedtask/pools?api-version=7.1-preview.1
...and then filter on the "isHosted" property - but the pool info has no run history.
Alternatively I can loop through all projects in the Org (lots!), loop through all pipelines, then finally loop through all runs for each pipeline - but the run doesn't have an agent property either.
I tried looking at Service Hooks to trigger a webhook when a build is run to see if I could pull the agent / pool detail from the payload - buts its not in there either.
Any other ideas welcome.
Upvotes: 1
Views: 251
Reputation: 7241
When encountered those situation, you always have two ways.
1, First of all, if UI can show what you want, you can handle the data via python crawler.
#python crawler get the content of the page
import requests
url = "https://dev.azure.com/<Organization Name>/_settings/agentpools?poolId=9&view=jobs"
payload={}
headers = {
'Authorization': 'Basic <Personal Access Token>',
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
#save the content to a file
with open('jobs.html', 'w', encoding='utf-8') as f:
f.write(response.text)
After saving the data, use the regular expression to filter the data you want.
(This method is just a suggestion for common handling.)
2, Or you can use this REST API to query the public agents run history of your current situation:
https://dev.azure.com/<Organization Name>/_apis/distributedtask/pools/<Pool ID>/jobrequests
Public or private can be distinguished by ParallelismTag:
Upvotes: 0