3

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.

user8973449
  • 175
  • 1
  • 11
  • Hello, is there any updates for this question? Please check whether my answer can help you and feel free to comment. – Jane Ma-MSFT Nov 25 '20 at 07:52

1 Answers1

1

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.

Jane Ma-MSFT
  • 4,461
  • 1
  • 6
  • 12
  • Thank you for this, but how should I proceed to get the correct value for the **releaseIdsFilter**? To get the information from this specific pipelines **Approval**? Is there any [Predefined variable](https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml) or similar, that would be suitable? – user8973449 Nov 25 '20 at 13:36
  • @user8973449 The release ids are determined by the order in which they are created. If the release is the first release of the project, its ID is 1. You can ignore this parameter if you have a better method to find your Approval. – Jane Ma-MSFT Nov 26 '20 at 01:49
  • I'm not sure that I understand what you mean. To clarify I'm using Pipelines inside of Azure Pipelines, not Releases. In regards of: _You can ignore this parameter if you have a better method to find your Approval_ - I don't have any better method, I dont't have any method at all to find it, hence (amongst other reasons) my original question. So, how could I configure your above answer, using the proposed REST API, from inside of my Pipeline (not Release) in Azure Pipelines, to get information about my Approval? Thank you for the effort you put in to this, I appreciate it. – user8973449 Nov 26 '20 at 15:52
  • @user8973449 I'm sorry to have misunderstood your question. I have re-read your question and updated my answer. If you still need the more complicated method, please feel free to let me know and I will update my answer for you. – Jane Ma-MSFT Nov 27 '20 at 09:35
  • I've voted for the feature at the provided link. In regards of _"If you still need the more complicated method, please feel free to let me know and I will update my answer for you."_ - please provide it, so that I can evaluate if it's applicable for my scenario, thank you! – user8973449 Nov 30 '20 at 12:45
  • Thank you for the update on the answer Jane, really appreciate that. I will try it out and see if it works for me. – user8973449 Dec 02 '20 at 13:29
  • @user8973449 Looking forward to hearing your good news~ If you have any new questions, feel free to comment. – Jane Ma-MSFT Dec 03 '20 at 09:38