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 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 the New Pipeline button as shown in the below screen.

Azure DevOps account

Select the 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'.

Repository name

Default branch

Azure DevOps Pipeline has many pre-defined templates to choose from according to the suitability of your needs. Here, we will select ASP.NET Template and click on 'Apply'.

ASP.NET Template

The template has 5 configuration steps as mentioned - Tasks, Variables, Triggers, Options, and Retention.

Let's check and configure step by step.

Configure

Step 1. Manage Tasks.

Using these settings, you can manage your pipeline agent's jobs.

Name: it is your artifact's name.

Artifacts name

Agent Pool

Agent Pool is a group of build and release agents, 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.

Installable software

Azure Pipelines has built agents using that you can target pretty much any platform, here you can see Hosted VS2017, Hosted macOS, Linux, Ubuntu, etc.

Agent Pool Architecture

Agent Pool Architecture

Image reference: https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/pools-queues?view=vsts 

Artifacts

Artifacts are the final output of this step 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 the +(plus) icon next to the Agent Job tab and you can see a variety of tasks and tools available for build, test, package, deploy, utilities, etc. You can add that as per the project's requirement.

Default artifacts

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 them by clicking on the +Add button.

Add button

Step 3. Using the trigger setting we can schedule the build time, we can set that continuous integration on any new check-in.

Trigger setting

Or we can specify a scheduled day and time to autorun the build. You can see here when to build branch filters where you can include or exclude a specific branch.

Specific branch

Step 4. From the 4th Tab which is the Options tab, we can manage general build pipeline settings. You can manage the 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.

Default settings

Step 5. Retention policies are nothing but your build history backup settings like keeping the build for 10 days or 30 days for N good builds.

History backup

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 the master branch), and click on the save and queue button.

Continuous Integration

Build pipeline

It will start the continuous integration process, you can see the logs by clicking on Build No.

Integration process

You can see that for the requested job, the agents are getting ready.

Requested job

Step by step it will execute all the jobs and tasks.

Tasks

Execute task

Once all jobs are executed successfully you can see the result on the builds dashboard.

Executed successfully

ASP

You can see the Build History by clicking on the 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 pipeline status, and associated changes for the latest changes or the latest build.

Build History

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.