DevOps help for Cloud Platform Engineers
  • Welcome!
  • Quick Start Guide
  • About Me
  • CV
  • 🧠DevOps & SRE Foundations
    • DevOps Overview
      • Engineering Fundamentals
      • Implementing DevOps Strategy
      • DevOps Readiness Assessment
      • Lifecycle Management
      • The 12 Factor App
      • Design for Self Healing
      • Incident Management Best Practices (2025)
    • SRE Fundamentals
      • Toil Reduction
      • System Simplicity
      • Real-world Scenarios
        • AWS VM Log Monitoring API
    • Agile Development
      • Team Agreements
        • Definition of Done
        • Definition of Ready
        • Team Manifesto
        • Working Agreement
    • Industry Scenarios
      • Finance and Banking
      • Public Sector (UK/EU)
      • Energy Sector Edge Computing
  • DevOps Practices
    • Platform Engineering
    • FinOps
    • Observability
      • Modern Practices
  • 🚀Modern DevOps Practices
    • Infrastructure Testing
    • Modern Development
    • Database DevOps
  • 🛠️Infrastructure as Code (IaC)
    • Terraform
      • Getting Started - Installation and initial setup [BEGINNER]
      • Cloud Integrations - Provider-specific implementations
        • Azure Scenarios
        • AWS Scenarios
        • GCP Scenarios
      • Testing and Validation - Ensuring infrastructure quality
        • Unit Testing
        • Integration Testing
        • End-to-End Testing
        • Terratest Guide
      • Best Practices - Production-ready implementation strategies
        • State Management
        • Security
        • Code Organization
        • Performance
      • Tools & Utilities - Enhancing the Terraform workflow
        • Terraform Docs
        • TFLint
        • Checkov
        • Terrascan
      • CI/CD Integration - Automating infrastructure deployment
        • GitHub Actions - GitHub-based automation workflows
        • Azure Pipelines - Azure DevOps integration
        • GitLab CI - GitLab-based deployment pipelines
    • Bicep
      • Getting Started - First steps with Bicep [BEGINNER]
      • Template Specs
      • Best Practices - Guidelines for effective Bicep implementations
      • Modules - Building reusable components [INTERMEDIATE]
      • Examples - Sample implementations for common scenarios
      • Advanced Features
      • CI/CD Integration - Automating Bicep deployments
        • GitHub Actions
        • Azure Pipelines
  • 💰Cost Management & FinOps
    • Cloud Cost Optimization
  • 🐳Containers & Orchestration
    • Containerization Overview
    • Docker
      • Dockerfile Best Practices
      • Docker Compose
    • Kubernetes
      • CLI Tools - Essential command-line utilities
        • Kubectl
        • Kubens
        • Kubectx
      • Core Concepts
      • Components
      • Best Practices
        • Pod Security
        • Security Monitoring
        • Resource Limits
      • Advanced Features - Beyond the basics [ADVANCED]
        • Service Mesh
        • Ingress Controllers
          • NGINX
          • Traefik
          • Kong
          • Gloo Edge
      • Troubleshooting - Diagnosing and resolving common issues
        • Pod Troubleshooting Commands
      • Enterprise Architecture
      • Health Management
      • Security & Compliance
      • Virtual Clusters
    • OpenShift
  • Service Mesh & Networking
    • Service Mesh Implementation
  • Architecture Patterns
    • Data Mesh
    • Multi-Cloud Networking
    • Disaster Recovery
    • Chaos Engineering
  • Edge Computing
    • Implementation Guide
    • Serverless Edge
    • IoT Edge Patterns
    • Real-Time Processing
    • Edge AI/ML
    • Security Hardening
    • Observability Patterns
    • Network Optimization
    • Storage Patterns
  • 🔄CI/CD & GitOps
    • CI/CD Overview
    • Continuous Integration
    • Continuous Delivery
      • Deployment Strategies
      • Secrets Management
      • Blue-Green Deployments
      • Deployment Metrics
      • Progressive Delivery
      • Release Management for DevOps/SRE (2025)
    • CI/CD Platforms - Tool selection and implementation
      • Azure DevOps
        • Pipelines
          • Stages
          • Jobs
          • Steps
          • Templates - Reusable pipeline components
          • Extends
          • Service Connections - External service authentication
          • Best Practices for 2025
          • Agents and Runners
          • Third-Party Integrations
          • Azure DevOps CLI
        • Boards & Work Items
      • GitHub Actions
      • GitLab
        • GitLab Runner
        • Real-life scenarios
        • Installation guides
        • Pros and Cons
        • Comparison with alternatives
    • GitOps
      • Modern GitOps Practices
      • GitOps Patterns for Multi-Cloud (2025)
      • Flux
        • Overview
        • Progressive Delivery
        • Use GitOps with Flux, GitHub and AKS
  • Source Control
    • Source Control Overview
    • Git Branching Strategies
    • Component Versioning
    • Kubernetes Manifest Versioning
    • GitLab
    • Creating a Fork
    • Naming Branches
    • Pull Requests
    • Integrating LLMs into Source Control Workflows
  • ☁️Cloud Platforms
    • Cloud Strategy
    • Azure
      • Best Practices
      • Landing Zones
      • Services
      • Monitoring
      • Administration Tools - Platform management interfaces
        • Azure PowerShell
        • Azure CLI
      • Tips & Tricks
    • AWS
      • Authentication
      • Best Practices
      • Tips & Tricks
    • Google Cloud
      • Services
    • Private Cloud
  • 🔐Security & Compliance
    • DevSecOps Overview
    • DevSecOps Pipeline Security
    • DevSecOps
      • Real-life Examples
      • Scanning & Protection - Automated security tooling
        • Dependency Scanning
        • Credential Scanning
        • Container Security Scanning
        • Static Code Analysis
          • Best Practices
          • Tool Integration Guide
          • Pipeline Configuration
      • CI/CD Security
      • Secrets Rotation
    • Supply Chain Security
      • SLSA Framework
      • Binary Authorization
      • Artifact Signing
    • Security Best Practices
      • Threat Modeling
      • Kubernetes Security
    • SecOps
    • Zero Trust Model
    • Cloud Compliance
      • ISO/IEC 27001:2022
      • ISO 22301:2019
      • PCI DSS
      • CSA STAR
    • Security Frameworks
    • SIEM and SOAR
  • Security Architecture
    • Zero Trust Implementation
      • Identity Management
      • Network Security
      • Access Control
  • 🔍Observability & Monitoring
    • Observability Fundamentals
    • Logging
    • Metrics
    • Tracing
    • Dashboards
    • SLOs and SLAs
    • Observability as Code
    • Pipeline Observability
  • 🧪Testing Strategies
    • Testing Overview
    • Modern Testing Approaches
    • End-to-End Testing
    • Unit Testing
    • Performance Testing
      • Load Testing
    • Fault Injection Testing
    • Integration Testing
    • Smoke Testing
  • 🤖AI Integration
    • AIops Overview
      • Workflow Automation
      • Predictive Analytics
      • Code Quality
  • 🧠AI & LLM Integration
    • Overview
    • Claude
      • Installation Guide
      • Project Guides
      • MCP Server Setup
      • LLM Comparison
    • Ollama
      • Installation Guide
      • Configuration
      • Models and Fine-tuning
      • DevOps Usage
      • Docker Setup
      • GPU Setup
      • Open WebUI
    • Copilot
      • Installation Guide
      • VS Code Integration
      • CLI Usage
    • Gemini
      • Installation Guides - Platform-specific setup
        • Linux Installation
        • WSL Installation
        • NixOS Installation
      • Gemini 2.5 Features
      • Roles and Agents
      • NotebookML Guide
      • Cloud Infrastructure Deployment
      • Summary
  • 💻Development Environment
    • Tools Overview
    • DevOps Tools
    • Operating Systems - Development platforms
      • NixOS
        • Installation
        • Nix Language Guide
        • DevEnv with Nix
        • Cloud Deployments
      • WSL2
        • Distributions
        • Terminal Setup
    • Editor Environments
    • CLI Tools
      • Azure CLI
      • PowerShell
      • Linux Commands
      • YAML Tools
  • 📚Programming Languages
    • Python
    • Go
    • JavaScript/TypeScript
    • Java
    • Rust
  • 📖Documentation Best Practices
    • Documentation Strategy
    • Project Documentation
    • Release Notes
    • Static Sites
    • Documentation Templates
    • Real-World Examples
  • 📋Reference Materials
    • Glossary
    • Tool Comparison
    • Recommended Reading
    • Troubleshooting Guide
  • Platform Engineering
    • Implementation Guide
  • FinOps
    • Implementation Guide
  • AIOps
    • LLMOps Guide
  • Development Setup
    • Development Setup
Powered by GitBook
On this page
  • Schema Reference
  • Basic Example
  • Template Example
  • Advanced Examples
  • Extending Templates with Multiple Stages
  • Template with Conditional Stages
  • Using Extends with Repository Templates
  • Best Practices for Template Extension
  • Template Extension Use Cases
Edit on GitHub
  1. CI/CD & GitOps
  2. CI/CD Platforms - Tool selection and implementation
  3. Azure DevOps
  4. Pipelines

Extends

The extends keyword allows you to create a pipeline that inherits from and extends a template. This approach is powerful for standardizing pipelines across your organization while still providing flexibility for individual projects.

Schema Reference

extends: # Required. Extends a template.
  template: string # The template referenced by the pipeline to extend.
  parameters: # Parameters used in the extend.
pool: string | pool # Pool where jobs in this pipeline will run unless otherwise specified.
name: string # Pipeline run number.
appendCommitMessageToRunName: boolean # Append the commit message to the build number. The default is true.
trigger: none | trigger | [ string ] # Continuous integration triggers.
parameters: [ parameter ] # Pipeline template parameters.
pr: none | pr | [ string ] # Pull request triggers.
schedules: [ cron ] # Scheduled triggers.
resources: # Containers and repositories used in the build.
  builds: [ build ] # List of build resources referenced by the pipeline.
  containers: [ container ] # List of container images.
  pipelines: [ pipeline ] # List of pipeline resources.
  repositories: [ repository ] # List of repository resources.
  webhooks: [ webhook ] # List of webhooks.
  packages: [ package ] # List of package resources.
variables: variables | [ variable ] # Variables for this pipeline.
lockBehavior: string # Behavior lock requests from this stage should exhibit in relation to other exclusive lock requests.

Basic Example

Here's a basic example of a pipeline that extends a template:

# azure-pipelines.yml
extends:
  template: templates/main-pipeline-template.yml
  parameters:
    projectName: 'MyProject'
    buildConfiguration: 'Release'

trigger:
  - main

pool:
  vmImage: 'ubuntu-latest'

Template Example

The template being extended (templates/main-pipeline-template.yml):

# templates/main-pipeline-template.yml
parameters:
  - name: projectName
    type: string
    default: 'DefaultProject'
  - name: buildConfiguration
    type: string
    default: 'Debug'

stages:
- stage: Build
  jobs:
  - job: BuildJob
    steps:
    - script: echo "Building ${{ parameters.projectName }} in ${{ parameters.buildConfiguration }} mode"
      displayName: 'Build Project'

- stage: Test
  jobs:
  - job: TestJob
    steps:
    - script: echo "Testing ${{ parameters.projectName }}"
      displayName: 'Test Project'

Advanced Examples

Extending Templates with Multiple Stages

# azure-pipelines.yml
extends:
  template: templates/enterprise-ci-cd-template.yml
  parameters:
    projectName: 'MyWebApp'
    environmentsToDeploy:
      - name: 'Development'
        serviceName: 'webapp-dev'
        serviceConnection: 'azure-dev'
      - name: 'Staging'
        serviceName: 'webapp-staging'
        serviceConnection: 'azure-staging'
        approvalRequired: true

trigger:
  branches:
    include:
      - main
      - release/*

variables:
  buildConfiguration: 'Release'
  dotNetVersion: '6.0.x'

Template with Conditional Stages

# templates/enterprise-ci-cd-template.yml
parameters:
  - name: projectName
    type: string
  - name: environmentsToDeploy
    type: object
    default: []
  - name: runSecurityScan
    type: boolean
    default: true

stages:
- stage: Build
  jobs:
  - job: BuildJob
    steps:
    - task: UseDotNet@2
      inputs:
        packageType: 'sdk'
        version: '$(dotNetVersion)'
    - script: dotnet build --configuration $(buildConfiguration)
      displayName: 'Build ${{ parameters.projectName }}'
    - task: DotNetCoreCLI@2
      displayName: 'Run unit tests'
      inputs:
        command: 'test'
        projects: '**/*Tests/*.csproj'
        arguments: '--configuration $(buildConfiguration)'

- ${{ if eq(parameters.runSecurityScan, true) }}:
  - stage: SecurityScan
    displayName: 'Security Scan'
    dependsOn: Build
    jobs:
    - job: RunSecurityScan
      steps:
      - script: echo "Running security scan on ${{ parameters.projectName }}"
        displayName: 'Security Scan'

# Dynamic stages for each environment
- ${{ each environment in parameters.environmentsToDeploy }}:
  - stage: Deploy_${{ environment.name }}
    displayName: 'Deploy to ${{ environment.name }}'
    dependsOn: ${{ if eq(parameters.runSecurityScan, true) }}:
      - SecurityScan
    ${{ else }}:
      - Build
    jobs:
    - deployment: Deploy
      environment: ${{ environment.name }}
      ${{ if eq(environment.approvalRequired, true) }}:
        strategy:
          runOnce:
            deploy:
              steps:
              - task: AzureWebApp@1
                displayName: 'Deploy to Azure Web App'
                inputs:
                  azureSubscription: '${{ environment.serviceConnection }}'
                  appName: '${{ environment.serviceName }}'
                  package: '$(System.ArtifactsDirectory)/**/*.zip'
      ${{ else }}:
        strategy:
          runOnce:
            deploy:
              steps:
              - task: AzureWebApp@1
                displayName: 'Deploy to Azure Web App'
                inputs:
                  azureSubscription: '${{ environment.serviceConnection }}'
                  appName: '${{ environment.serviceName }}'
                  package: '$(System.ArtifactsDirectory)/**/*.zip'

Using Extends with Repository Templates

Templates can be stored in different repositories and reused across multiple projects:

# azure-pipelines.yml
resources:
  repositories:
    - repository: templates
      type: git
      name: DevOpsTemplates/pipeline-templates
      ref: refs/tags/v1.0

extends:
  template: dotnet-web-app-ci-cd.yml@templates
  parameters:
    projectName: 'CustomerPortal'
    sonarQubeProject: 'customer-portal'
    artifactName: 'website'

Best Practices for Template Extension

  1. Standardize Core Build Logic: Keep core build, test, and deployment logic in templates to ensure consistency across projects.

  2. Use Parameters for Flexibility: Design templates with parameters to accommodate different project requirements without modifying the template itself.

  3. Version Your Templates: Use tags or specific branch references when extending templates from a shared repository to ensure stability.

  4. Template Composition: Create specialized templates for different types of projects (e.g., web apps, APIs, libraries) that can extend more generic base templates.

  5. Document Template Parameters: Clearly document the required and optional parameters for each template to facilitate adoption.

  6. Include Validation: Add parameter validation in your templates to catch configuration errors early.

  7. Multi-stage Templates: Design templates that cover the entire CI/CD process, from build to deployment across multiple environments.

  8. Environment Specific Logic: Use conditionals to include environment-specific steps (e.g., additional security checks for production).

Template Extension Use Cases

  1. Standardized CI/CD Pipelines: Create organizational standards for different application types.

  2. Compliance Enforcement: Ensure all projects follow security and compliance requirements by embedding them in templates.

  3. Accelerating New Projects: Provide ready-to-use pipeline templates for new projects, reducing setup time.

  4. Multi-environment Deployment: Create templates that handle the complexity of deploying to multiple environments with appropriate approvals.

  5. Cross-platform Applications: Use templates with matrix strategies to build and test applications on multiple platforms.

PreviousTemplates - Reusable pipeline componentsNextService Connections - External service authentication

Last updated 1 day ago

🔄