Learn about the components in Azure DevOps Pipeline
Azure DevOps pipelines are structured with several key components that define how automation is performed across different stages of the software delivery lifecycle. Below is an expanded view of these components along with deployment strategies and lifecycle hooks.
1. Pipeline
A pipeline represents a CI/CD workflow that automates building, testing, and deploying software. It includes stages, jobs, steps, and other configuration elements that manage the flow of the pipeline.
2. Stage
A stage is a logical grouping of jobs within a pipeline. Each stage represents a specific phase, such as Build, Test, or Deploy. Multiple stages can be used for different environments (e.g., Development, Staging, Production).
Example:
xxxxxxxxxx71stages2stageBuild3 jobs4jobBuildJob5 steps6scriptecho "Building..."7 displayName'Run Build Command'3. Job
A job represents a set of steps executed on a specific agent. Jobs within a stage can run in parallel or sequentially.
Example:
xxxxxxxxxx41jobs2jobDeployJob3 steps4scriptecho "Deploying..."4. Steps
Steps are the individual actions or tasks performed within a job. They can execute scripts, run tasks, or invoke other pipelines.
Example:
xxxxxxxxxx31steps2scriptdotnet restore3 displayName'Restore Dependencies'5. Tasks
Tasks are pre-defined actions or operations that are added to a step. Tasks provide functionality like running scripts, installing tools, or managing deployments.
Example:
xxxxxxxxxx41steps2taskPublishBuildArtifacts@13 inputs4 buildDirectory$(Pipeline.Workspace)/artifacts6. Deployment Strategies
Deployment strategies define how a release or deployment is managed and can vary based on how the release is rolled out to different environments.
a. RunOnce
Deploys once to a specified environment.
Example:
xxxxxxxxxx81jobs2deploymentDeployOnce3 environment'Production'4 strategy5 runOnce6 deploy7 steps8scriptecho "Deploying to Production"b. Rolling
Deploys to multiple environments incrementally, rolling forward.
Example:
xxxxxxxxxx81jobs2deploymentRollingUpdate3 environment'Staging'4 strategy5 rolling6 deploymentTimeoutInMinutes307 batchCount28 rollBackOnFailuretruec. Canary
Deploys a subset of traffic to a new environment and monitors performance before expanding to the full environment.
Example:
xxxxxxxxxx111jobs2deploymentCanaryRelease3 environment'Staging'4 strategy5 canary6 firstExitCriteria7 count508 intervalInMinutes59 secondExitCriteria10 count10011 intervalInMinutes157. Lifecycle Hooks
Lifecycle hooks define steps that execute before or after key deployment stages, enabling more control and flexibility. They can handle actions such as rolling back deployments, verifying configurations, or managing routing of traffic.
Lifecycle Hooks
preDeploy: Runs before deployment begins.
deploy: Executes immediately after deployment.
routeTraffic: Handles traffic routing after deployment.
postRouteTraffic: Runs after traffic is successfully routed.
on:failure: Executes specific steps when a deployment or stage fails.
on:success: Executes specific steps when a deployment or stage succeeds.
Example:
xxxxxxxxxx111jobs2deploymentProductionDeployment3 environment'Production'4 strategy5 runOnce6 deploy7 steps8scriptecho "Deploying to Production"9 postRouteTraffic10 steps11scriptecho "Post-deployment monitoring"Example Full Pipeline with Deployment Strategies and Lifecycle Hooks
xxxxxxxxxx501trigger2main3variables4 buildConfiguration'Release'5pool6 vmImage'ubuntu-latest'7stages8stageBuild9 displayName'Build Stage'10 jobs11jobBuildJob12 steps13checkoutself14scriptdotnet restore15 displayName'Restore Dependencies'16scriptdotnet build --configuration $(buildConfiguration)17 displayName'Build Solution'18stageDeploy19 displayName'Deploy Stage'20 jobs21deploymentDeployToProduction22 environment'Production'23 strategy24 runOnce25 deploy26 steps27scriptecho "Deploying to Production"28 preDeploy29 steps30scriptecho "Running pre-deployment checks"31 routeTraffic32 steps33scriptecho "Routing traffic to new deployment"34 postRouteTraffic35 steps36scriptecho "Post-deployment monitoring"37stageCanary38 displayName'Canary Release'39 dependsOnDeploy40 jobs41deploymentCanaryDeployment42 environment'Canary'43 strategy44 canary45 firstExitCriteria46 count5047 intervalInMinutes548 secondExitCriteria49 count10050 intervalInMinutes15Summary
| Component | Description |
|---|---|
| Pipeline | A CI/CD workflow managing build, test, and deployment automation. |
| Stage | Represents a logical grouping of jobs within a pipeline. |
| Job | A set of steps executed on an agent. |
| Steps | Individual actions or tasks within a job. |
| Tasks | Predefined or custom actions within steps. |
| Deployment Strategies | Techniques to deploy to different environments (RunOnce, Rolling, Canary). |
| Lifecycle Hooks | Actions executed at specific stages (preDeploy, deploy, routeTraffic, etc.). |






















Leave a Reply