Continuous Integration Using Azure DevOps Pipelines And .NET Project

In my previous article, we saw what is new in Azure DevOps. In this article, we will learn what Azure Pipelines are and how to use these to implement continuous integration for a .NET Web Application.
 
Azure Pipeline is mainly used to continuously build, test, and deploy to any platform and cloud. You can create a cloud-hosted pipeline for Windows, Linux, and macOS and with unlimited minutes.
 
With the automation of your build and deployment process, you can have more time to perform more productive and creative work. Compared to VSTS, Azure Pipelines are much faster. 
 
Let's see how to set and build a pipeline for continuous integration.
 
Login to your Azure DevOps account and choose Pipelines, Builds. If it is your first time, you can also select New Pipeline button as shown in the below screen.
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project
 
Select your repository for which you want to set-up a build, and for that, first select a source from the given options like, Azure Repos Git, gitHub, Subversion Bitbucket cloud etc. Here, we will select Azure Repos git which is a default source.
 
Select the Team project, Repository name, and branch from which you want to set-up Build and then click on 'Continue'.
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project 
 Continuous Integration Using Azure DevOps Pipelines And .NET Project
Azure DevOps Pipeline has many pre-defined templates to choose from according to the suitability of your need. Here, we will select ASP.NET Template and click on 'Apply'.
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project 
 
The template has 5 configuration steps as mentioned - Tasks, Variables, Triggers, Option, and Retention.
 
Let's check and configure step by step. 
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project 
 
Step 1 - Manage Tasks
 
Using these settings, you can manage your pipeline agent's jobs.
 
Name - it is your artifacts name.
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project
 
Agent Pool
 
Agent Pool is the group of build and release agent, to build and deploy your code you need at least one agent.
 
An agent is an installable software that runs one build or deployment job at a time.
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project 
 
Azure Pipelines has build agents using that you can target pretty much any platform, here you can see Hosted VS2017, Hosted macOS, Linux, Ubuntu etc.
 
Agent Pool Architecture
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project 
Image reference: https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/pools-queues?view=vsts 
 
Artifacts
 
Artifacts are the final output of this steps or process. Artifacts are the actual build files or packages produced by this process.
 
The drop is a default artifacts folder name.
 
Lastly,  you can manage and customize agent jobs as per your project requirements. For adding a new job click on +(plus) icon next to Agent Job tab and you can see varieties of tasks and tools available for build, test, package, deploy, utilities etc. You can add that as per the project's requirement.
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project 
 
Step 2
 
Variables give us a convenient way to get key data into various parts of the pipeline. There are system predefined variables and you can also create user-defined variables as per your need. For more details click here.
 
Here we have a setup of build configuration in the release mode, Build Platform = any CPU, system.debug mode false.
 
If you have any variables to add, you can add that by clicking on a +Add button.
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project 
 
Step 3
 
Using the trigger setting we can schedule the build time, we can set that continuous integration on any new check-in.
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project 
 
Or we can specify a scheduled day and time to autorun the build. You can see here when to build and branch filters where you can include or exclude a specific branch.
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project 
 
Step 4
 
From the 4th Tab which is the Options tab, we can manage general build pipeline settings. You can manage Build Number Format (you can also customize the build number format), enable or disable automatic linking to new work in this build, set up the branches and build job settings etc. 
 
Here, I will save the default settings.
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project 
 
Step 5
 
Retention policies are nothing but your build history backup settings like keeping build for 10 days or 30 days for N good builds.
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project 
 
This will automatically delete the old builds that are not in use.
 
Step 6
 
You can save the Continuous Integration and queue it later or if you want to start continuous integration manually then click on save and queue. it will open a popup. Select the agent pool from the popup, select the branch (here I have selected master branch) and click on save and queue button. 
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project 
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project 
 
It will start the continuous integration process, you can see the logs by clicking on Build No.
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project 
 
You can see that for the requested job, the agents are getting ready.
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project 
 
Step by step it will execute all the job and tasks.
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project 
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project 
 
Once all jobs are executed successfully you can see the result on the builds dashboard.
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project 
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project 
 
You can see the Build History by clicking in history tab. If you want to see the progression, click on the build number from the grid, it will display all the progression shown as per the below screen.
 
You can see the build artifact's published details, build pipelines status and associated changes for the latest changes or latest build.
 
Continuous Integration Using Azure DevOps Pipelines And .NET Project 
 
I hope you like this article. In my next article, we will explore the Azure Test Plan in detail.
 
Please give your feedback or comments in the comment box.