Azure DevOps Pipelines: Leveraging Stages with YAML Objects
This an excerpt of an article written for Microsoft Tech Community Blog. To read the whole article click here. Additionally if you’d like the entire series of blog posts on YAML pipelines can be found on the Microsoft Health and Life Sciences blog site.
By now we’ve covered the basics on tasks, jobs, stages, environments, variables and templates for jobs and tasks. It is now time to move towards stage templates. Additionally, to assist with templating we will cover one way to leverage YAML objects which is a key tool when templating up and keeping your pipelines DRY (Don’t Repeat Yourself).
To follow along I am leveraging non-ADO code in from Azure IaC Flavors and YAML templates from TheYAMLPipelineOne
Recapping from a pervious post, a stage is:
Stages are the level above jobs. A stage is required; however, there is a default if one is not provided. A stage can contain one to many jobs and acts as a logical grouping of related jobs.
An important component to understand is that Azure DevOps, out of the box, provide an easy way to rerun Pipelines at the stage level. This means our stages should be constructed with jobs that make sense to re-run together. Usually, customers want to naturally associate a stage with a customer environment. I’d advise fighting this temptation.