Code Sharing (PowerShell): Create Pull Request via VSTS REST API

Visual Studio Team Services Git Love

This past week I started concentrating on optimizing our release processes. I’ve talked about how our team uses VSTS and Git in a previous post. At the end of a sprint, pull requests are created in all of our repositories to merge to the release branches. As the number of our repositories continues to grow, the number of manual steps to merge for releases grows exponentially. Having worked with the VSTS REST API in the past I knew this wouldn’t be difficult to automate. A build would be run that runs the script below for each of our repositories to create pull requests. Service hooks to Slack would then send notifications so the necessary reviewers can approve the newly created pull requests. This same script can be used post release to merge back to Master branches. I commented on every line of code in the script below so I didn’t have to go into details here 🙂

One thought on “Code Sharing (PowerShell): Create Pull Request via VSTS REST API

  1. I have been looking for a solution for the exact same problem. Merging code automatically from Release branch to all user branches. The script is beautifully written explaining every detail in comments. Thank you very much for sharing the same.

Leave a Reply

Your email address will not be published. Required fields are marked *