Azure DevOps For Web Development - CI And Build Pipelines - Part Three

Scope
 
This article is part three of a series of four articles on getting an ASP.NET Web App live on Azure App Services using Azure Repos and Azure Pipelines. The previous articles described how to create your Azure DevOps account, create a project, and push your code to Azure Repos using Git.
This is the third article of the series and will walk you through automating your builds each time code is updated in your repository.

Continuous Integration (CI) With Azure Pipelines

Continuous Integration (CI) is the automation of builds and testing of code each time changes are pushed to your code repository; it helps to catch bugs or problems early in the development cycle, which makes them easier and faster to fix.
 
Azure Pipelines is the Continuous Integration / Continuous Delivery service in Azure DevOps that can build any language targeting any platform. Azure Pipelines has hosted pools of Windows, Linux, & Mac machines that it manages for you so that all your focus is on developing features for your product.
 
Build Pipeline
 
Our next step continuing off from the last article is to automate the build process of the .NET web app each time code is pushed to our repository. Jump to ‘Builds’ under ‘Pipelines’ or press the keyboard shortcut G B. (Check out all the Azure DevOps Keyboard Shortcuts).
 
Next, click on ‘New Pipeline’.
Azure DevOps For Web Development - CI And Build Pipelines
 
Azure Pipelines supports Azure Repos, GitHub, Bitbucket, Subversion External Git repositories as a source for the build pipelines.
 
Select ‘Azure Repos’, input the correct Project, Repository & Branch (the default is master in this case). Hit Continue.
Azure DevOps For Web Development - CI And Build Pipelines 
 
You will be presented with a wide variety of readymade built templates to build pretty much everything from Android and iOS Apps, Docker, Go Applications, and much more. We’ll go for the ASP.NET template.
 
Azure DevOps For Web Development - CI And Build Pipelines 
 
The next screen will show the details of the different steps in the build template we’ve chosen.
 
The output of this build pipeline is called the Artifact. Artifacts are the collection of files or packages produced by the build and used in subsequent tasks, such as distribution or deployment. By default, the artifact is called ‘drop’.
 
Azure DevOps For Web Development - CI And Build Pipelines 
 
You will notice that as mentioned before, Azure Pipelines has build agents that let you target pretty much any platform, and also supports private build agents.
 
Azure DevOps For Web Development - CI And Build Pipelines 
 
In your case, there’s no change needed in this template. But if you want to customize this build pipeline, click on the little ‘+’ button on top, and you will get to choose from a wide range of first-party and third-party tasks you can drag and drop into the build pipeline.
 
Azure DevOps For Web Development - CI And Build Pipelines 
 
One last thing that we need to do is to enable Continuous Integration in the Triggers tab so the build tasks run automatically each time we push changes to the repository.
 
Azure DevOps For Web Development - CI And Build Pipelines 
 
Click on "Save". The Build Pipeline is now ready.
 
To test out the build pipeline, make some changes to your local ASP.NET code and push the code to the online repository using the commands described in the previous article.
 
Azure DevOps For Web Development - CI And Build Pipelines 
 
As soon as the code is pushed, you will see in the Azure DevOps web portal that a build is already in the queue and running.
 
Azure DevOps For Web Development - CI And Build Pipelines 
 
Clicking on the commit title will show you the build details & logs in real time, and you can follow the console output for any warnings or errors.
 
Azure DevOps For Web Development - CI And Build Pipelines 
 
After a few minutes, the automatic build is complete.
 
Azure DevOps For Web Development - CI And Build Pipelines 
 
And the build artifact is available, you can explore its content by clicking on ‘Artifacts’, then select ‘drop’ in the menu.
 
Azure DevOps For Web Development - CI And Build Pipelines 
 
As soon as the build is completed, you are also notified by email. You are not required to constantly check the Azure DevOps, it’s basically a "set-up and forget".
 
Azure DevOps For Web Development - CI And Build Pipelines 

Conclusion

In this part of the Azure DevOps for Web Development series, you have seen how to automate your builds in the cloud using Azure Pipelines, which produced an artifact. In the next article of the series, you will see how to use this artifact to automate your deployments using Release Pipelines.

See also