Azure DevOps YAML Pipelines

Multi-Stage CI/CD YAML Pipelines are a fairly new feature in Azure DevOps. They offer some great advantages versus the classic GUI Pipelines. One of the biggest advantages is that your entire CI/CD Pipeline is now represented in a single YAML file that can be checked in and tracked with your version control system of choice. As with a lot of things I write about, this is an incredibly deep and complex topic. There's no way to fit every little minute detail into one article. So, this will be a fairly high level overview.

The prior Pipelines experience was built around the GUI editors found on the Azure DevOps website. You can still access and use these classic experiences if you wish:

GUI Build Pipelines can be found under: Pipelines > Create Pipeline > Use the classic editor:

No alt text provided for this image

GUI Release Pipelines can still be found under: Releases > New Pipeline

No alt text provided for this image

So, what's the new method? Simply create a file named "azure-pipelines.yml" and define your Build and Release Pipelines as 100% code!

Of course, this brings some challenges with it. The biggest being that you'll have to learn the proper format & schema for the YAML file. Microsoft has a great reference online, which you can find here. But, understanding the major building blocks of the YAML Pipeline will get you a long way there. I'll go over those building blocks below.

No alt text provided for this image

Stages

A Pipeline is made up of one or more Stages. Stages are major divisions in a Pipeline. Stages are logical boundaries in your Pipeline, which you can use to pause your Pipeline and perform various checks. By default, Stages run sequentially. Each Stage starts only after the preceding stage is complete.

Jobs

Stages are made up of one or more related Jobs. Jobs are a unit of work assignable to an Azure DevOps "agent". The agent ultimately performs the work included in the Job. The agent can be a machine hosted by Microsoft or a machine that you host yourself.

A single agent can only run one Job at a time, so if you only have one agent then your Jobs will run sequentially, one after the other. If you have multiple agents, and you have the required amount of Parallel Jobs, then multiple Jobs can be run on multiple agents in parallel. To control this, you can utilize conditions and dependencies. For example, start Job 2 only if Job 1 has completed successfully.

Jobs come in two forms, a regular Job and a 'Deployment' Job. Both types of Jobs can live in the same Stage. It's recommend to put your deployments steps into a Deployment Job versus a regular Job. Deployment Jobs provide two major benefits:

  1. Deployment history: You get the deployment history across pipelines, down to a specific resource and status of the deployments for auditing.
  2. Apply deployment strategy: You define how your application is rolled out. This can be rolling, canary, or run once.

Steps

Jobs are made up of one or more Steps. Steps can be a task to run or a script to execute. Steps are run sequentially, one after another. Before a step can start, all the previous steps must be finished (or skipped).

Azure DevOps includes a big library of built-in tasks which you can use. You can see the full catalog here. There are tasks for building/compiling your code, testing your code, installing required tools, using packages and package repositories, deploying your app, and many more.

If you have custom things that you would like to do that aren't covered by one of the built-in tasks, then you can always just create your own custom script and run that.

Summary

I think that's plenty of information for an introductory article. As stated earlier, this is an incredibly deep topic and I already have follow-up articles in mind for the future.


#azure #azuredevops #devops #yaml #azurepipelines #pipelines

Sources:

Nicholas Hughes

Former CEO of EITR Technologies (successful exit) | Automator of Things | Just a Guy? | The Salt Guy | Pipe Symbol Enthusiast | Are you seriously still reading this?

4 年

Great article Nathan! Super informative and very well written.

要查看或添加评论,请登录

Nathan Nellans的更多文章

  • Quick Primer on the PowerShell shell

    Quick Primer on the PowerShell shell

    Microsoft defines PowerShell as being made up of three main components. First, it is a modern command shell.

    1 条评论
  • Which Azure service to use?

    Which Azure service to use?

    Azure has a ton of services to pick from. You can see the full list here: https://azure.

  • Terraform - Deploying WVD in Azure

    Terraform - Deploying WVD in Azure

    Lately, I've been playing around with Windows Virtual Desktop (WVD) in my personal sandbox. I wanted to see if I could…

    2 条评论
  • Kubernetes - kubectl & kubeconfig Files

    Kubernetes - kubectl & kubeconfig Files

    kubectl is the command-line tool that is used to interact with Kubernetes clusters. But, how does kubectl know which…

    3 条评论
  • Kubernetes - API Versions & Resources

    Kubernetes - API Versions & Resources

    When I sat down to write this article, it was originally titled Top 4 things that confused me about Kubernetes…

  • All about Azure Cloud Shell

    All about Azure Cloud Shell

    Azure Cloud Shell is an interactive, in-browser shell environment. It has two different shell experiences, either Bash…

    2 条评论
  • How to connect Terraform Cloud with both Azure and Azure DevOps Services

    How to connect Terraform Cloud with both Azure and Azure DevOps Services

    This article is sort of like a Part 2. You see, I wrote a previous article that discussed connecting Terraform Cloud…

    3 条评论
  • Azure Storage Options

    Azure Storage Options

    When you create a new Storage Account in Azure you will find there are a lot of different options to select from. It…

  • Overview of email security options: SPF, DKIM, and DMARC

    Overview of email security options: SPF, DKIM, and DMARC

    If you send emails from your own custom domain name then you should really think about implementing all 3 of these…

  • Active Directory Domain Services options in Azure

    Active Directory Domain Services options in Azure

    I have a long history of working with traditional Active Directory Domain Services (AD DS). I am very familiar when it…

社区洞察

其他会员也浏览了