Creating your first Azure DevOps Build Pipeline

22 april 2020 om 10:58 by ParTech Media - Post a comment

As a developer, you need to write, test and deploy your software in a production environment. But while the process remains the same, it isn’t always automatic. To automate most of the activities in this process, you need to create and release a CI/CD pipeline. And this is exactly where Azure Pipelines come to play.

In the simplest terms, Azure Pipelines (part of Azure DevOps) is a cloud service that can be used for automating the process of building, testing, and deploying your code. Post testing, the code will be immediately available to your teammates. Since the Azure Pipelines is compatible with most project types and almost all programming languages, many developers are using it.

Why is it useful?

Azure Pipelines are incredibly useful to say the least. It offers a easy to use interface for automating your integration and delivery which takes away manual labor and chance of failure. Here are a couple of benefits of using Azure Pipelines.

  • Compatible with almost all programs languages and platforms.
  • Deploys multiple targets simultaneously.
  • Can be integrated with your Azure deployment.
  • Can be used on Windows, Linux, and Mac systems.
  • You can easily integrate it with your GitHub Repository.

Creating an example Azure Build Pipeline

Here’s a quick walkthrough on creating your first pipeline.

First let me point out that there is a difference between Build and Release pipelines. As you probably guessed; Build pipelines are used to build the source code of your project into a working application whereas Release pipelines are there to release it to different environments.

In our guide, we will discuss how exactly you can leverage a build pipeline for building a repository on Github.

What will I need?

  • Since you’ll create the repository on Github, you’ll need your own Github account.
  • You’ll also need an Azure DevOps account for your organization. In case you don’t have it yet, click here to create a free account. It is worth noting here that a DevOps organization account isn’t the same as your GitHub Organization account.
  • Finally, when you’re done creating the account, set yourself as the administrator of the DevOps project you’re looking to undertake.

Creating a new Build Pipeline

To start the process, fork the following repository into your GitHub account: https://github.com/MicrosoftDocs/pipelines-dotnet-core

This will be the sample application that we are going to build with our Pipeline. Once you’re done copying the repository, here’s what you need to do next:

  • Sign in to your organization’s Azure DevOps account.

  • Locate your project and click the Pipelines option and select Builds.

  • Select the action for creating new pipelines.

  • Now, follow the instructions of the wizard and choose Github as your source code’s location.

  • If you’re redirected to the login page of GitHub, sign in with your credentials.

  • You’ll now find a list of repositories from which you can choose the sample repository you've created earlier.

  • Once you do this, Azure Pipelines will instantly assess the repository and suggest a template for a new Pipeline.

  • Click Save and run and choose Commit directly to the master branch option from the drop down.

  • Click the Save and run option once again.

  • This will immediately start a new run. Wait for its completion.

Copying an existing Pipeline from the same project

If you would like a copy of an existing pipeline of your current project, you can just clone it. Alternatively, if the pipeline is not available in the current project, leverage the import/export feature to initiate the cloning.

  • Open your YAML editor of your existing pipeline and copy the code.
  • Now paste it in the YAML editor of the new Azure DevOps Pipeline.
  • You can now customize or tweak this cloned pipeline.

Importing/exporting Pipelines from a different project

If you want to copy the Azure pipeline from a different project, you can use the Import/Export option. Here are the steps you need to follow.

  • Open your YAML editor and click the pipeline you’re looking to export.
  • Click the three vertical dots beside the Run Pipeline option and choose the Export option from the dropdown menu.
  • You will now get a prompt to save the YAML file in your system. After this, the file will be automatically saved in your system’s download directory.
  • To importing the pipeline, click the landing page of your pipelines and click the Import option from the dropdown.
  • As with the previous process you will get a new prompt for selecting the YAML file and importing the contents. Navigate to and select the file you initially exported.
  • Once the import is completed, you can directly access the new pipeline.

Note: When you export a pipeline, project specific details about your agent pools will be reset. In this case, you will need to re-enter the relevant data.

Bottom Line

You should now have a basic idea of what an Azure Build Pipeline does and how you create it.
Stay tuned for another article on this topic, explaining how to create custom tasks that you can use in a Pipeline!