You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Azure Pipelines is the CI/CD engine within Azure DevOps. It automates the process of building, testing, and deploying your applications to any platform, cloud, or on-premises environment. With YAML-based pipeline definitions, your CI/CD configuration lives alongside your code, making it version-controlled, reviewable, and repeatable.
CI is the practice of automatically building and testing code every time a developer pushes changes. The goal is to catch issues early and maintain a deployable codebase.
# azure-pipelines.yml
trigger:
branches:
include:
- main
- feature/*
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '20.x'
displayName: 'Install Node.js'
- script: npm ci
displayName: 'Install dependencies'
- script: npm run lint
displayName: 'Run linter'
- script: npm test -- --coverage
displayName: 'Run tests'
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/junit.xml'
displayName: 'Publish test results'
- task: PublishCodeCoverageResults@2
inputs:
summaryFileLocation: '**/coverage/cobertura-coverage.xml'
displayName: 'Publish code coverage'
CD extends CI by automatically deploying the build artifacts to one or more environments:
Code Push → Build → Test → Deploy to Staging → Approval → Deploy to Production
trigger:
branches:
include:
- main
stages:
- stage: Build
jobs:
- job: BuildApp
pool:
vmImage: 'ubuntu-latest'
steps:
- script: npm ci && npm run build
displayName: 'Build application'
- publish: $(System.DefaultWorkingDirectory)/dist
artifact: app-build
- stage: DeployStaging
dependsOn: Build
jobs:
- deployment: DeployToStaging
environment: staging
strategy:
runOnce:
deploy:
steps:
- download: current
artifact: app-build
- task: AzureWebApp@1
inputs:
azureSubscription: 'my-service-connection'
appName: 'webapp-staging'
package: '$(Pipeline.Workspace)/app-build'
- stage: DeployProduction
dependsOn: DeployStaging
jobs:
- deployment: DeployToProduction
environment: production
strategy:
runOnce:
deploy:
steps:
- download: current
artifact: app-build
- task: AzureWebApp@1
inputs:
azureSubscription: 'my-service-connection'
appName: 'webapp-production'
package: '$(Pipeline.Workspace)/app-build'
| Trigger Type | Description |
|---|---|
| CI trigger | Runs on push to specified branches |
| PR trigger | Runs when a pull request is opened or updated |
| Scheduled | Runs on a cron schedule |
| Pipeline trigger | Runs when another pipeline completes |
| Manual | Triggered manually from the Azure DevOps UI |
# Scheduled trigger — nightly build
schedules:
- cron: '0 2 * * *'
displayName: 'Nightly build'
branches:
include:
- main
always: true
# PR trigger
pr:
branches:
include:
- main
paths:
exclude:
- docs/*
- '*.md'
Agents are the machines that execute your pipeline:
| Agent Type | Description | Best For |
|---|---|---|
| Microsoft-hosted | Pre-configured VMs managed by Microsoft (Ubuntu, Windows, macOS) | Standard builds, no maintenance |
| Self-hosted | Your own machines (physical, VM, or container) | Custom tooling, compliance, network access |
| Image | OS |
|---|---|
ubuntu-latest | Ubuntu 22.04 LTS |
windows-latest | Windows Server 2022 |
macos-latest | macOS 14 (Sonoma) |
# Register a self-hosted agent
./config.sh --unattended \
--url https://dev.azure.com/myorg \
--auth pat \
--token <PAT> \
--pool "Linux Agents" \
--agent "agent-01"
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.