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:
Standardize Core Build Logic: Keep core build, test, and deployment logic in templates to ensure consistency across projects.
Use Parameters for Flexibility: Design templates with parameters to accommodate different project requirements without modifying the template itself.
Version Your Templates: Use tags or specific branch references when extending templates from a shared repository to ensure stability.
Template Composition: Create specialized templates for different types of projects (e.g., web apps, APIs, libraries) that can extend more generic base templates.
Document Template Parameters: Clearly document the required and optional parameters for each template to facilitate adoption.
Include Validation: Add parameter validation in your templates to catch configuration errors early.
Multi-stage Templates: Design templates that cover the entire CI/CD process, from build to deployment across multiple environments.
Environment Specific Logic: Use conditionals to include environment-specific steps (e.g., additional security checks for production).
Template Extension Use Cases
Standardized CI/CD Pipelines: Create organizational standards for different application types.
Compliance Enforcement: Ensure all projects follow security and compliance requirements by embedding them in templates.
Accelerating New Projects: Provide ready-to-use pipeline templates for new projects, reducing setup time.
Multi-environment Deployment: Create templates that handle the complexity of deploying to multiple environments with appropriate approvals.
Cross-platform Applications: Use templates with matrix strategies to build and test applications on multiple platforms.