Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Create a Dev Pipeline in Azure DevOps

Apr 2, 2020 • 6 Minute Read

Introduction

In a world filled with automation and DevOps tooling, the top contender is Continuous Integration and Continuous Delivery (CICD). CICD provides the ability to not only automate the shipment of software, but to do it in a reliable and efficient way without risking quality engineering. With the power of a good CICD platform and app, you can ensure that end-users receive continuous value.

When working with a CICD platform, the main goal is to build production-ready releases for code, and in this guide you will learn just that. You will perform a real-world example approach on how to create a development pipeline in Azure DevOps. Since the pipeline is for development purposes, you will learn how to create one stage for Dev. After the stage is created, you will create a build pipeline to package up an app and turn the code into an artifact. After the code is turned into an artifact, you will have an app ready to deploy for a release pipeline.

Prerequisites

To follow along with this blog post you should ensure that you have any type of code committed to a GitHub repository that you have access to. This blog post will use the C# code found in my GitHub repository here.

Building the Pipeline

In this section, you will take a hands-on approach at creating a development build pipeline in Azure DevOps to package up code into an artifact that is ready to be shipped to end-users. In some organizations, the build pipeline may also be called the Continuous Integration (CI) pipeline. The purpose of CI is to build and test code every time a developer commits changes to version control. With that typically comes building an artifact, which is why you may hear "build pipeline" and "CI pipeline" used interchangeably.

Creating the Pipeline

Before creating the artifact, the initial pipeline needs to be created. In this portion of the guide, you will start the creation of the pipeline.

Log into the Azure DevOps portal.

Go to Pipelines —> Pipelines to access the pipelines pane.

Within the pipelines pane, click the blue New pipeline button.

Choosing the GitHub Repository

Under the Where is your code? section, choose GitHub. This allows you to select the code that you want to build and turn into an artifact.

For this example, on the Select a repository page the CloudDevWebBoilterPlate repository was chosen, which is the repository linked in the prerequisites section.

Creating the YAML Pipeline

In the Configure your pipeline section, choose Starter pipeline. The starter pipeline allows you to create a pipeline from scratch to add in any tasks that suit your needs in building the app.

On the Review your pipeline YAML page, remove lines 13-19 so the code looks like the screenshot below. These linesaren't needed because they're pseudocode.

Click the Show assistant button as shown in the screenshot below to add the two tasks that are needed to create the build pipeline.

The two tasks that you will need to add are:

  • Copy files - This task copies the code from the linked GitHub repository and stores it in the pipeline to be used in the next task. The target folder is a predefined Azure DevOps variable which is a local path on the pipeline agent.

  • Publish build artifacts - This tasks takes the copied code from the Copy files task and creates an artifact out of the copied code. The path to publish uses the same predefined variable as shown in the Copy files task because that's where the code was copied to. The Publish build artifacts task needs to look in that location to create an artifact out of the code.

Click the blue Add button on both tasks and you should see code similar to the below.

      trigger:
    - master
    
    pool:
      vmImage: 'ubuntu-latest'
    
    steps:
    - task: CopyFiles@2
      inputs:
        SourceFolder: 'web'
        Contents: '**'
        TargetFolder: '$(Build.ArtifactStagingDirectory)'
    - task: PublishBuildArtifacts@1
      inputs:
        PathtoPublish: '$(Build.ArtifactStagingDirectory)'
        ArtifactName: 'drop'
        publishLocation: 'Container'
    

Deploying the Pipeline

Click the blue Save and run button to run the build pipeline.

The code for the YAML pipeline creates a azure-pipelines.yml file that needs to be stored where the code that is being built and turned into an artifact exists. On the Save and run page, put in a commit message or leave the default and commit directly to master, because the existing code is linked in the prerequisites section of the GitHub repository .

Click the blue Job button so you can see the code being built and turned into an artifact.

Congratulations! You have successfully created and deployed a build pipeline.

Conclusion

In this guide, you took a hands-on approach to create a build pipeline. You started off by initializing the pipeline and creating the first development stage. Following that, you pointed the pipeline to the code in GitHub that was going to be built and turned it into an artifact in the pipeline. Finally, you created the new type of pipeline in Azure DevOps, called YAML pipelines, to deploy the copy and publish tasks to create an artifact out of the code.

Michael Levan

Michael L.

Michael Levan is a seasoned engineer and consultant who spends his time working with startups and enterprises around the globe on cloud and DevOps projects. He also performs technical research as an analyst, creates real-world, project-focused content, and coaches engineers on how to cognitively embark on their engineering journey. Want to see what he is up to? https://www.clouddev.engineering/ or Twitter @TheNJDevOpsGuy

More about this author