The Azure function that can detect the pull requests linked to work items has any commit dependency loss on the target branch.
- Following the official document to set up an HTTP Triggered function example in VSCode. Here we use
.NET 6.0
as this project’s developing environment. - Create & deploy the function in Azure, and retrieve the URL of the function.
- Go to the Azure DevOps project setting page and create webhooks when pull requests are raised and updated. Use the URL from the previous steps as the target URL so that it will invoke the function every time there are new PRs.
- Go to
User setting / Personal access tokens
page to create a PAT that has the following authorization:- Code: Status
- Pull Request Threads: Read & Write
- Work Items: Read
- Go to the Azure
Function App / Configuration / Applicaiton settings
section to add the PAT into environment variable for the function app.
Go to Function App / Configuration / Applicaiton settings and set up the variable likes:
"GROUP_1_TRIGGER":"sit-r22, rc-043",
"GROUP_1_TARGET": "sit-r22, rc-043, sit-r23, rc-044, master, sit",
"GROUP_2_TRIGGER":"sit-r23, rc-044",
"GROUP_2_TARGET": "sit-r23, rc-044, master, sit",
"GROUP_OTHER_BRANCHES": "master, sit"
- Query work items from pull request
- Query linked pull requests from work item
- Query commits from pull request
- Query all commits from target branch (use ?searchCriteria.itemVersion.version={targetBranch} as parameter)
- Create check result status on pull request page
- Create new comment thread on pull request page