Azure DevOps PR Validator is a web service which can validate title of a pull request in Azure DevOps Services and inform it about pull request's validity.
- User creates or updates pull request.
- Azure DevOps invokes Web Hook which sends information about pull request to validator app.
- Validator validates pull request and posts validation result through Azure DevOps REST Status API.
- Pull request page shows status's result and may enforce positive status requirement through Branch policies.
- install Deno: https://deno.land/#installation
- [for development] install Denon: https://deno.land/x/denon#install
- [VS Code extension] install extension with id: denoland.vscode-deno
deno bundle src/index.ts app.bundle.js
deno run --allow-net --allow-env app.bundle.js [<port>]
or
deno run [--cert <path to corporate CA PEM certificate>] --allow-net --allow-env app.bundle.js [<port>]
in corporate environment
API access token must be set in environment variable TFS_API_KEY
. See https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate for instructions how to create PAT. Required token scope is just Code/Status.
In Azure DevOps go to Project Settings and create two new Service Hooks of type Web Hook triggered on: Pull request created and Pull request updated. Configure filters as per your needs. Set it to send HTTP request to: <validator IP or url>:<port (default is 8000)>/validate-pr/title
.
In Azure DevOps go to Branch policy and add new requirement under Require approval from additional services with Status to check = tfs-pr-validator/title-validation
.