Build Pipelines in Azure DevOps

16 September 2020 at 10:00 by ParTech Media - Post a comment

In a traditional system, the role of a developer would involve understanding the requirement, analyzing, designing, developing and unit testing the solution, later the same code will be checked-in to a repository. After this, the operations team would pick the code, build, and publish the code to the corresponding environments.

With the advent of DevOps, right from understanding the requirement to publishing the code has become the responsibility of a developer. So, does DevOps increase the workload for developers? No, it has made it much easier for the developers. It does this by providing an automated way to complete the process that was being done by the operations team previously. DevOps provides two main automated practices - Continuous Integration and Continuous Deployment. In this post, we are going to introduce CI and then understand build pipelines in Azure DevOps in detail.

Table of Contents

  1. What is Continuous Integration?
  2. Introduction to Azure DevOps
  3. What is Azure Pipelines?
  4. Features of Build Pipeline
  5. Practical Implementation of build pipelines in Azure DevOps
  6. Wrapping up

What is Continuous Integration?

Continuous integration is a development practice where developers integrate their code for a feature into a shared repository frequently. The success of integration can be verified by an automated build and automated tests, although the latter is not mandatory.

The key benefits of integrating continuously are early detection of errors and locate them easily. Each change that is integrated will be small and easy to analyze. This will help in jotting down the error.

Example - there is a codebase for software X and in the repository, there is a master branch for the solution X. Now, a user A creates a new branch from the master branch and makes the changes for a feature. Later, he checks-in the changes to the new branch.

Once the changes for the features are completed, user A has to merge the changes from the new branch to the master branch and run a build to validate the code is intact. This process of merging the code from the feature branch to the master branch and running the build with the merged code is called Continuous Integration.

Introduction to Azure DevOps

Azure DevOps is a Software as a Service (SaaS) offering from Microsoft. It provides end-to-end DevOps tools for developing and deploying the software.

It provides a wide range of services which include Azure boards, Azure Pipelines, Azure Repos, Azure Artifacts, Azure Test Plans.

We are going to see in detail about Azure pipelines in this article.

What is Azure Pipeline?

Azure pipelines are a set of services in Azure DevOps that provides the option to create, run, monitor, and maintain Pipelines in the cloud platform. It is a cloud, language, and platform-agnostic CI/CD platform with support for containers or Kubernetes.

Since the build and release pipelines can be automated using the Azure pipelines, it saves a lot of time for the team.

Features of Build Pipeline

Let's see some important features of the Build pipeline in this section.

Platform and language independent

Users can use the operating system of their choice and they can also decide what language to use to build the application.

Azure extensions

Build pipelines provide access to many predefined build tasks to customize the pipeline based on the user's need, thereby helping the team in building and unit testing the code.

Supports deployment to other cloud vendors

Azure pipelines provide the freedom to deploy the build application using azure build pipelines to different cloud platforms like Amazon Web services (AWS), Google cloud platform (GCP), etc..,

Practical implementation of a build pipeline

  1. To create build pipelines, users have to choose the Azure pipelines option present in the dashboard, then on Pipelines.

  2. Here, users will be able to see the already created pipelines or they will be allowed to create a new build pipeline by selecting the 'New pipeline' option.

  3. The next step is to choose the code which the users want to build. Azure build pipeline provides options to build the solution that is present in Azure Repos, Bitbucket, GitHub, and other git-based repositories.

  4. Once the user clicks on the appropriate repository where the code has been stored, the user will be prompted to enter the credentials of the corresponding repository.

  5. Next, users will be also requested to Azure DevOps to access the repository, to fetch the solution and do the build. In case if the repository is in the same Azure DevOps account, then users will not be prompted with steps 4 and 5.

  6. In the build pipeline wizard, the next step is to select a template for the YAML based build configuration file. In this step, users are provided with templates to get started with. Users can choose the template based on their needs.

  7. On choosing the template, users will take the last and final step in creating the build pipeline, where they will be able to view the YAML configuration file with the default name as 'azure-pipelines.yml'.

  8. On the same screen, users will be provided the option to 'save and run' the pipeline. On clicking on the option, a modal popup screen opens on the right side of the screen where it provides the option to check-in the azure-pipelines.yml file to the code repository.

  9. On clicking 'Save and Run' from the previous screen, the file will be created and checked-in to the repository and the build will also start.

  10. Build progress can be monitored and the green checkmarks next to each task on the summary page denote that the build pipeline got executed successfully.

    Image Source: https://jpvelasco.com/build-aspnet-framework-apps-with-azure-pipelines/

  11. Once the build runs successfully, it creates an artifact that stores the compiled version of the code that needs to be published.

In case the users want to edit some tasks in the build pipeline, then users can make use of the edit option and modify the pipeline content. Similar to the save and run option, after editing, users can save the pipeline and the same will be checked-in to the code repository.

Wrapping Up

Azure pipelines feature supports YAML based build pipelines which allow users to check-in the same in the code repositories. Also, it provides an option to view and edit the build pipeline from the browser. In the next blog, we are going to see in detail about the release pipeline in Azure DevOps.

Latest