Repository navigation
Add tool to list pull request policy evaluations #1550
Damien Lecan (dlecan)
started this conversation in
Backlog of Suggestions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
No tool reports why a pull request is blocked.
repo_pull_requestreturnsmergeStatus, votes andcompletionOptions, but never the policy results, and the statuses API does not cover branch policies. #843 raised this and was closed as completed without a tool shipping, same for #1276.The policy evaluations API does cover them, and it is already reachable through
getPolicyApi()in the official Node API. It also answers the original ask in #843: thecontextof a build evaluation carriesbuildId,buildDefinitionId,buildIsNotCurrentandisExpired, so a pull request id can be traced to its build validations.Tools
Develop the following tool with full parameter support, including optional ones:
repo_list_pull_request_policy_evaluations: List branch policy evaluation results for a pull request.Endpoint: GET https://dev.azure.com/{organization}/{project}/_apis/policy/evaluations?artifactId=vstfs:///CodeReview/CodeReviewId/{projectId}/{pullRequestId}&api-version=7.1-preview.1
REST docs: https://learn.microsoft.com/en-us/rest/api/azure/devops/policy/evaluations/list
Node API:
getPolicyApi().getPolicyEvaluations(project, artifactId, includeNotApplicable?, top?, skip?)Three things worth knowing before implementing, all verified against a live organization:
vstfs:///CodeReview/CodeReviewId/{projectId}/{pullRequestId}, not thevstfs:///Git/PullRequestId/...value thatrepo_pull_requestreturns for the same pull request;api-version=7.1is rejected, the preview suffix is required;status,configuration.id,configuration.isBlocking,configuration.type.displayNameandcontext. Callers needconfiguration.idto match againstcompletionOptions.autoCompleteIgnoreConfigIds, because a policy withisBlocking: falsestill holds auto-complete unless its id is listed there. Without that pairing, a pull request whose every readable field says "ready to merge" can sit unmerged with no way to explain it.Rules
I can test a build of this against a live organization with the policies above, and open a PR if that helps.
All reactions