Search code examples
azure-devopsyamlazure-devops-rest-apimultistage-pipeline

How to get stage results from YAML pipelines in Azure DevOps


Until now, I am using the Azure DevOps REST Api to get the data from releases in Azure DevOps for reporting purpose. Obviously, this will change with the new way how to use CI/CD --> YAML and the Multi-Stage-Pipeline (currently preview). In that case the build- and release-strategy is deprecated and everything is defined as a pipeline and subdivided into staged (build stage, deploy stage 1, deploy stage 2, ...).
I tried to receive data via the build list method, but this data is limited and I am missing some important information like 'was stage successful'.

Does anybody have already experience with the compination of YAML Pipelines and the Azure DevOps REST Api? Is there a way to get the full data (as with classic release strategy)? Or is it currently under development and I have to be patient?

Thanks in advance!


Solution

  • How to get stage results from YAML pipelines in Azure DevOps

    For this issue, you need to use Status - Get rest api.

    GET https://dev.azure.com/{organization}/{project}/_apis/build/status/{definition}?api-version=5.1-preview.1
    

    This api can get the build status for a definition, optionally scoped to a specific branch, stage, job, and configuration.

    Here is my test with postman: enter image description here enter image description here

    Update Second way:

    You can press F12 in the browser then select Network to capture the request to get the stage result.You can capture the result from the response body. But different stage results are represented by different numbers i.e 0->completed,5->canceled etc.

    enter image description here enter image description here