Azure DevOps — Pull request validation for a multi .net solution in a large git repo

Thejas`Gowda
4 min readSep 13, 2018

Microsoft provides a lot of features to make your application cloud ready. which in turn make it easy to adopt a DevOps culture in software development.

You can go through the below link to understand the service provided by Azure DevOps by Microsoft. Visual studio team services(VSTS) is now renamed as Azure DevOps. https://visualstudio.microsoft.com/team-services/

Pull request(PR) and code review is one of the main concepts of the development process, Which will help you to build a quality code.

Azure DevOps tool will give a couple of option to set up this process easily. While working with a large code base with multiple application in a single git repository, I come across a situation where I want to build only the application which I made changes to.

Consider an example, I have a repo with multiple application within it and each application is maintained by the corresponding team of developers.

Multiple apps in same repo

The above picture shows 2 apps(MyContact and MyLogin independent apps) in the same repo. when I develop a new feature for MyLogin app my code changes will contain a code corresponding to MyLogin. So it is not necessary to build MyContact app for MyLogin changes.

Below steps will show how we can achieve the goal.

Step 1: Set up build in Azure

Select git repo to set up build
Select an inbuilt build template depending on your app
Select the solution file(For my case I setting up a build for MyLoginApp, same can be followed for other apps)

Click save and queue. After the end of step 1, you will have a build which runs on your solution.

Step 2: Setup branch policies

Click on the marked icon to set up policies for master branch
Click on Build policy to set up builds for changes

Select the build created in step 1, and provide the path filter.

Path filter is the main part of build selection. This is the list of the folder path. In the above example, /MyLogin/* — Selects build whenever it find any changes in MyLogin folder. You may come across a situation where your app is depending on another app to consider this scenario I have provided a one more path /SharedProjects/* with ; separated. So now any changes to SharedProjects it will run MyLogin build as well. That ensures no impact on the consuming app.

Similarly, I have created a build for the MyContact app and build for the shared project.

MyContact build — Will run on any changes to my contact code also on any shared project code.

MyLogin build — Will run on any changes to my login code also on any shared project code.

SharedProject build- Will run on any changes to shared code

Build validation for each app with path filters

Step 3: Create a pull request and validate the setup

MyLogin changes trigger only MyLogin build

The above picture shows the PR raised for my logic which contains changes only to mylogin code. So triggers corresponfing build i.e MyLogin build.

Multiple builds triggered for shared code change

In the above picture, I have changed the shared code and raised the PR. You can see 3 builds got triggered to validate changes. This ensures all dependent projects build successfully before code merges to master.

Git repo URL used for this article: https://thejas007.visualstudio.com/MultiSolutionBuild/_git/MultiSolutionBuild

--

--