Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a REST API to get the build errors in Azure DevOps?

So, here is what I know:

  1. I can get the build data, there I can find the logs property with a url.
  2. Accessing the logs url returns an array of links to the various parts of the build log (presumably a part per build task in the order of the latter in the build definition)
  3. The url in each part gets me the text logged by the respective task.
  4. I can parse it and everything matching ##[error] corresponds to an error logged on the build summary page.

I am curious if this is the best way to do it if I only need to get the build errors. I do not need the whole log.

like image 566
mark Avatar asked Oct 30 '25 16:10

mark


1 Answers

You can also use the Build Timeline API and check the results there if there is an errors.

The API response contains the property issues, so just check if it's not null and print the issue message.

For example (in PowerShell):

# Get here the response from the api
$response = Invoke-RestMethod ......
$errors = $response.records.Where({ $_.issues -ne $null })
$errors.ForEach({
   # Task name
   $_.name
   # Error message
   $_.issues.ForEach({ $_.message })
})
like image 123
Shayki Abramczyk Avatar answered Nov 02 '25 13:11

Shayki Abramczyk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!