'Accessing raw GitHub pull_request webhook payload from triggered Azure Pipeline

We have an Azure yaml pipeline that uses the standard PR trigger to run some validation at PR open, modify, and close. We're able to use the System.PullRequest.PullRequestNumber pre-defined system variable to fetch and use the PR number. (We use this to form a unique terraform workspace name.) This is working great, except when the PR is closed, in which we are finding the PullRequestNumber is not set. :-(

Clearly, the GH docs on PR webhook indicate that the PR number is included. I don't see any reason why this wouldn't be the case even if action==closed.

I'm currently assuming this misbehavior is an Azure Pipelines bug, in which it is not correctly translating the pr number from the webhook payload into the System.PullRequest.PullRequestNumber variable.

This begs the question, is there a way to access the raw GitHub event payload from an ADO pipeline that is using standard pr: triggers?



Solution 1:[1]

According to your description, I supposed that you want to get the pull request id when the pull request is closed.

enter image description here

From the official documentation, this is impossible, as the pr trigger only supports triggering the pipeline when the pull request is created and triggering when the derived branch changes again. To obtain relevant information such as the id of the pull request, you firstly need to be triggered by the pr trigger. If you are not triggered by the pr trigger, obviously, that is impossible to obtain the relevant information of the pr. If there is any misunderstand, Please correct me ASAP.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jeremy Caney