Building a CI Pipeline with Azure Pipelines
Define a YAML pipeline that triggers on pull requests, runs unit tests, and produces a build artifact, then review test results and code coverage in the portal.
What Is Continuous Integration?
Continuous Integration (CI) is the practice of frequently merging code changes into a shared branch, with each merge automatically triggering a build and test run. The goal is to detect integration failures early — before they compound into large, hard-to-fix problems. A good CI pipeline builds the code, runs unit tests, measures code coverage, performs static analysis, and produces a deployable artifact in a few minutes. Azure Pipelines provides the automation engine for this practice.
YAML Pipeline Structure
Azure Pipelines CI pipelines are defined in a azure-pipelines.yml file at the root of your repository. The YAML file specifies triggers (when to run), a pool (which agent type to use), and a hierarchy of stages, jobs, and steps. Stages run sequentially by default. Jobs within a stage run in parallel by default. Steps within a job run sequentially. This structure gives you fine-grained control over the pipeline's execution flow.
# azure-pipelines.yml skeleton
trigger:
branches:
include:
- main
- 'feature/*'
paths:
exclude:
- docs/**
- '*.md'
pool:
vmImage: ubuntu-latest
variables:
buildConfiguration: Release
nodeVersion: '18.x'
stages:
- stage: CI
displayName: 'Build and Test'
jobs:
- job: Build
displayName: 'Build Application'
steps: []All lessons in this course
- Azure DevOps Services Overview
- Building a CI Pipeline with Azure Pipelines
- Continuous Deployment to Azure
- GitHub Actions on Azure