Azure DevOps - Auto Approve PR with PAT
I hear a lot of people ask, how can I problematically approve a PR when using Azure DevOps? See the example script below. You will need a valid PAT, Azure DevOps Org URL, Azure DevOps Project Name/ID. You will have to make small adjustment to the code to work, so please see comments inline. import argparse import json import requests # Go ahead and add all the users you want to approve with a PAT # This is the easiest way, otherwise we would have to run a lot of # api requests to figure out the user identity based on the current # PAT used TEAM = [ 'user1@example.com', 'user2@example.com', ] def submit_to_api(pat=None, url=None, data=None, method="get", return_type='json', json=None): result = None if method == 'get': query_parameters = data headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} if query_parameters: result = requests.get...