0
votes

I've set up an environment in Azure Pipelines, containing a manual approval step. When the pipeline reaches the approval step, I get the choice to either approve, or reject the deployment with an optional comment included.

When I've taken and acted upon my decision, to either approve or reject the deployment, and added a comment for my decision, I can go back and look at the pipeline run to see the comment and if it was approved or rejected, as shown below:

Illustration of approval information

Is there any way, to retrieve this comment inside of the current run of the pipeline, to be able to use it in a pipeline task?

As soon as someone has approved/rejected with a comment, I need to be able to retrieve this comment further down the pipeline.

1
Hello, is there any updates for this question? Please check whether my answer can help you and feel free to comment.Jane Ma-MSFT

1 Answers

0
votes

As of this time, however, getting the comment of the approval in pipeline is not supported.

To get the comment in pipeline, you would need to use two REST APIs that are extracted by Developer Console (F12), which would be very cumbersome to implement.

You can vote for a new feature at this link, and Microsoft's product team will seriously consider adding the feature in future releases.

Update:

You can use the REST API to do this:

POST https://dev.azure.com/{organization}/_apis/Contribution/HierarchyQuery/project/{project}?api-version=5.0-preview.1

The REST API is not documented, and I found it in Developer Console (F12 in most browsers).

Here is an example of request body:

{
    "contributionIds": [
        "ms.vss-build-web.checks-panel-data-provider"
    ],
    "dataProviderContext": {
        "properties": {
            "buildId": "{build id}",
            "stageIds": "{stage id}",
            "checkListItemType": 1,
            "sourcePage": {
                "routeValues": {
                    "project": "{project}"
                }
            }
        }
    }
}

For buildId, You can use predefined variable Build.BuildId to get it.

For stageIds, You need to run another REST API, which is not documented as well:

GET https://dev.azure.com/JaneMaTest1/Case1130/_build/results?buildId=58&__rt=fps&__ver=2

You can get stage ids in fps -> dataProviders -> data -> ms.vss-build-web.run-details-data-provider -> stages -> id of the response body.