How To Build a CI/CD Pipeline In Azure DevOps ?

What is a CI/CD Pipeline?

  1. Source Stage — In most cases, when a change is attempted to the central repository, a pipeline run is triggered. These triggers are set by the CI/CD pipeline tool in the source stage.
  2. Build Stage — The combination of source code and its dependencies when building into a runnable instance corporate to the end-user application. The built-in application languages like Java need compilation too, which is done in the build stage. If docker images are to be constructed, that can also be facilitated in this stage. Failing this stage marks a potential error in the code or its dependencies.
  3. Test Stage — This stage corresponds to automated tests running to validate our code and its behavior accordingly. This stage acts as a sieve that prevents the bugs from reaching the end-user. There can be multiple stages, from smoke tests to end to end testing integration. Failure at this stage will expose errors in the code.
  4. Deploy Stage — Once we have a runnable code, the deployment is processed with all predefined tests passed. There are a lot of stages like “Beta,” “Staging,” etc., for the product team. A “Production” stage for the end-users is also present.

What is Azure DevOps?

  • Azure Repos
  • Azure Pipelines
  • Azure Boards
  • Azure Test Plans
  • Azure Artifacts

What is Azure Pipelines?

Advantages of Azure Pipelines:

  1. Version Control Systems — Having the code into a version control system is the first step of building an Azure CI/CD pipeline. You can manage your source code in GitHub, Bitbucket, Subversion, or any other Git repository. It also supports Team Foundation Version Control (TFVC).
  2. Programming Languages and Application Types — You can use different languages with Azure pipelines like Java, Ruby, C, C++, Python, PHP, Go, and JavaScript.
  3. Deployment Targets — The applications with Azure CI/CD pipelines can be deployed to multiple target environments. This includes Virtual Machines, Containers, or any On-prem or Cloud Platform.
  4. Pricing — It is free for public projects. But, for private projects, you can run up to 1800 minutes of pipeline jobs free per month.

How to build Azure CI/CD Pipeline?

  1. Create an ASP.NET sample DevOps project using Azure DevOps Starter resource in Azure.
  2. Examine Azure CI/CD pipelines configured by Azure DevOps Starter.
  3. Clone the sample DevOps project to the system.
  4. Commit the code and execute CI/CD.
  1. You will need an active Azure account for creating Azure Repos and Pipelines. You can create a Microsoft Azure Account for the same.
  2. For creating a sample app, we will be using Visual Studio and .NET Core. You can download Visual Studio and get .NET Core from the .NET Download Archives page.

Creating an ASP .NET DevOps Project using Azure DevOps Starter

  1. Sign in to your Azure account at the Microsoft Azure Portal.
  2. Select the + Create a Resource button under the Azure Services, and then search for DevOps Starter.
  • A team project with sample .NET code repository.
  • An Azure Web App and Azure SQL Database (if the database toggle was selected) in Azure.
  • Build Pipeline to compile and test the application.
  • Release Pipeline to deploy the application.

Examining the CI/CD Pipeline of the Sample DevOps Project

  1. On the top of the Azure Dashboard, there are options of both Build Pipelines and Release Pipelines. On clicking on any of the options, a new browser tab gets open up with the Pipeline.
  1. Click on the Build Pipelines on the Azure Dashboard.
  2. After the new browser tab opens up, select Edit from the top-right of the screen.
  1. Select Releases under the Pipelines section from the left side.
  2. The release pipeline manages the deployments in Azure DevOps. Click on Edit to examine the pipeline.
  3. Below the release pipeline’s name, you will find the same tabs as in the build pipeline.
  4. Under the Pipeline tab, go to the Artifacts, and select Drop. The build pipeline we examined before is the output to the Artifact.
  • Azure Resources Deployment — This deploys all the Azure resources like Azure Web App and Azure SQL Database for application usage.
  • Azure App Service Deploy — This deploys the application package to a website.
  • Azure SQL Database Deployment — The SQL changes are deployed to the database.
  • Visual Studio Tests — This runs functional tests after deployment.

Cloning the Sample DevOps Project Repository

  1. On the Azure Dashboard, click on the project’s name from the left pane. A new window opens up.
  2. On the new window, click on the Clone button from the top-right of the screen and copy the repository URL.

Commit the code and execute CI/CD

  1. The sample project we have created has a Git Repository in Azure DevOps Organization, which can be viewed in Azure Repos. The same repository has been cloned in Visual Studio 2019 via the previous steps.
  2. In the Visual Studio 2019 solutions explorer, navigate to Application/aspnet-core-dotnet-core/Pages/Index.cshtml file.
  3. Double-click the Index.cshtml to open it. Add a text line “This is a test message” in the division class “content — body.”
<div class="content-body">
<div class="success-text">Success!</div>
<div class="description line-1"> Azure DevOps Project has been successfully setup</div>
<div class="description line-2"> Your ASP.NET Core app is up and running on Azure</div>
<div class="description line-3">This is a test message.</div>
<br />

Integrating Azure DevOps With LambdaTest Account for bug tracking

  1. Login to LambdaTest Account.
  2. Go to Integrations and select Azure DevOps to integrate Azure DevOps with your LambdaTest account.
  3. After LambdaTest Azure DevOps CI/CD integration, go to the Real Time Testing option.
  4. Place your Project URL in the required URL field; to find the URL of the project, go to the Project details, and in the right pane, you will find a browse button. Right-click and copy the link address, and paste it to the URL field on the LambdaTest portal.

Working on the Bug Reported by LambdaTest, by creating a new Branch

  1. On clicking on Create branch, under Development, give the branch’s name and select the bug reported from LambdaTest.

Working on the Bug Reported by LambdaTest, by Commit/Pull Request

  1. When clicked on a commit/pull request, you have to specify the Link type, the Commit ID, and Comment.

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Harshit Paul

Harshit Paul

I am a product growth specialist at LambdaTest. He is also an experienced IT professional, who loves to share his thoughts about the latest tech trends.