使用 Rest API 获取 Azure DevOps 构建的构建结果

Get build result of a Azure DevOps build using Rest API

我正在尝试获取 Azure DevOps 构建的结果,即通过 REST API 成功/失败,以便我可以使用结果来对下一个构建进行排队。

我使用了下面的 powershell 脚本来获取构建细节。但是status只提供构建成功与否的信息'Completed',构建成功与否我们无法获取。

$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

我已经尝试使用这个 link 来获得构建结果。也试图获取构建定义,但也没有提供构建结果的信息。我也尝试了日志,同样的问题。 感谢任何帮助。

status 是构建的当前状态(进行中,已完成等),结果状态在 属性 result 中,检查您的 responseFromGet.result.