Microsoft Certified: DevOps Engineer ExpertDesign and implement source controlMedium
You are designing a new build pipeline in Azure DevOps for a microservices application. Each microservice has its own Git repository and needs to be built independently. The build process for each microservice is similar but requires specific parameters (e.g., service name, Docker image tag). You want to minimize duplication of YAML code and ensure consistency across all microservice builds. Which Azure DevOps pipeline feature should you use?
- ATask groups
- BTemplates
- CEnvironment variables
- DPipeline decorators
Show answer & explanationAnswer & explanation
Correct answer: B. Templates
Templates in Azure DevOps pipelines allow you to define reusable YAML snippets or full pipelines, which can then be parameterized and included in other pipelines. This is ideal for minimizing duplication and ensuring consistency across similar build processes for multiple microservices.
Why the other options are wrong
- A. Task groups are for grouping a sequence of tasks in the classic editor, not for YAML pipeline reusability across multiple independent repositories/pipelines.
- C. Environment variables are for passing values to tasks, but they don't provide a mechanism for structuring and reusing pipeline YAML code itself.
- D. Pipeline decorators inject tasks at predefined points in a pipeline, but are not designed for reusable, parameterized build logic across multiple distinct pipelines.
Azure DevOps Pipeline Templates
Reusable YAML files that define common pipeline structures, stages, jobs, or steps, allowing for parameterization and inclusion in multiple pipelines.
- Reduces YAML duplication and promotes consistency.
- Supports parameters for customization.
- Can be used for stages, jobs, steps, or even entire pipelines.
Memory trick: Think of pipeline templates as LEGO blocks for your builds: you design a block once, then use it everywhere, just changing a few colors (parameters).