AK123
AK123

Reputation: 445

Get build result of a Azure DevOps build using Rest API

I am trying to get the result of a Azure DevOps build i.e Succeeded / Failed via the REST API, so that I can use the result to queue the next build or not.

I have used the below powershell script to get the build details. But the status only provides the information if the build 'Completed' or not, we do not get the information if the build succeeded or not.

$Urinew = "https://<Org>/<project>/_apis/build/builds/"
$Uri2 = $Urinew+$buildId+"?api-version=5.0"
$responseFromGet = Invoke-RestMethod -Method Get -ContentType application/json -Uri $Uri2 -Headers @{Authorization=("Basic {0}" -f $base64authinfo)}
Write-host $responseFromGet
$status = $responseFromGet.status

I have tried to use this link to get the build result. Tried to get the build definition too, but that also does not provide the information of the build Result. I tried the logs too, again same issue. Any help is appreciated.

Upvotes: 2

Views: 3185

Answers (1)

Shayki Abramczyk
Shayki Abramczyk

Reputation: 41765

The status is what the current status of the build (in progress, completed etc. ), the result status is in the property result , check your responseFromGet.result.

Upvotes: 2

Related Questions