0
votes

Can I get access to an approver's id and comment when they approve a pending stage in Azure Devops Pipelines?

My pipeline has a stage that is dependent upon a reviewer to approve it before it runs. When they approve it they can type in a comment. Is this comment data + their approvers id available as a variable in the stage of the pipeline that runs as an effect of this approval?

1
Hi bitsofinfo, how's this ticket? Have you figured out it? Just checking to see if my reply helped or gave a right direction.PatrickLu-MSFT

1 Answers

0
votes

According to your description, looks like you just want to get the pre-deployment approval during the deployment.

To get the pre-deployment approval, you can use the REST API Get release:

GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/releases/{releaseId}?api-version=5.1`

For the release id, you can use the predefined variable $( Release.ReleaseId). And you can get the per-deployment approval from the response as below:

    "preApprovalsSnapshot": {
        "approvals": [
            {
                "rank": 1,
                "isAutomated": false,
                "isNotificationOn": false,
                "approver": {
                    "displayName": "yeye",
                    "url": "xxx",
                    "_links": {
                        "avatar": {
                            "href": "xxx"
                        }
                    },
                    "id": "18cb43b4-0b0d-43ad-94dc-c8e2b56704c0",
                    "uniqueName": "****@****.com",
                    "imageUrl": "xxx",
                    "descriptor": "msa.YjE2YzFlOWUtNWJkYy03NzU1LWJjNWEtNDU4M2Q5ZThlMjk0"
                },
                "id": 0
            }
        ],
        "approvalOptions": {
            "requiredApproverCount": null,
            "releaseCreatorCanBeApprover": true,
            "autoTriggeredAndPreviousEnvironmentApprovedCanBeSkipped": false,
            "enforceIdentityRevalidation": false,
            "timeoutInMinutes": 0,
            "executionOrder": "beforeGates"
        }
    }

enter image description here

enter image description here

enter image description here

Finally, you could use the got approver ID/Name, comments and pass them as an argument to a powershell script.

Hope this helps.