Understanding the Pipeline structure in Azure DevOps
In Azure DevOps, a pipeline is the top-level structure that automates software delivery. Within a pipeline, you create stages, jobs, steps, and define tasks to execute different stages of your CI/CD workflow. Additionally, deployment strategies and lifecycle hooks enable fine-grained control over deployments and can manage different release scenarios.
1. Pipeline
A pipeline is the highest level in the hierarchy, comprising stages that represent phases in the CI/CD process. Each stage can have multiple jobs.
Example Structure:
xxxxxxxxxx121pipeline2 name'MyPipeline'3stages4stageBuild5 jobs6jobBuildJob7 steps8scriptecho "Building the project"9stageDeploy10 jobs11deploymentDeployToProd12 environment'Production'2. Stage
A stage groups multiple jobs, representing logical units of work (e.g., build, test, deploy). Stages are linked together in a sequential or parallel flow.
Example:
xxxxxxxxxx111stages2stageBuild3 jobs4jobBuildJob5 steps6scriptecho "Building the project"7stageTest8 jobs9jobTestJob10 steps11scriptecho "Running tests"3. Job
Jobs are individual tasks performed on a single agent within a stage. A job contains steps that execute a sequence of commands or tasks.
Example:
xxxxxxxxxx31jobBuildJob2 steps3scriptecho "Building the application"4. Steps
Steps define individual actions within a job. They can be simple commands or complex tasks with dependencies.
Example:
xxxxxxxxxx51steps2scriptdotnet restore3 displayName'Restore Dependencies'4scriptdotnet build --configuration Release5 displayName'Build Solution'5. Tasks
Tasks are predefined actions provided by Azure DevOps or custom scripts used in a pipeline step.
Example:
xxxxxxxxxx51steps2taskUseDotNet@23 inputs4 packageType'sdk'5 version'6.x'6. Deployment Strategies
Azure DevOps provides various deployment strategies to handle different deployment patterns:
a. RunOnce
Deploy once to a specific environment without any further rollbacks or retries.
Example:
xxxxxxxxxx61deploymentDeployToProd2 strategy3 runOnce4 deploy5 steps6scriptecho "Deploying to Production"b. Rolling Deployment
Gradually rolls out a deployment to a subset of instances before completing the entire deployment.
Example:
xxxxxxxxxx61deploymentDeployToProd2 strategy3 rolling4 batchCount55 preDeploytrue6 postDeploytruec. Canary Deployment
Deploys to a small subset of users or servers first, ensuring minimal risk before scaling up.
Example:
xxxxxxxxxx51deploymentDeployToProd2 strategy3 canary4 count25 postRouteTraffictrue7. Lifecycle Hooks
Lifecycle hooks allow you to define custom actions at specific stages in the deployment process, such as before or after deploying changes.
a. preDeploy
Execute actions before deploying changes.
Example:
xxxxxxxxxx51deploymentDeployToProd2 strategy3 canary4 count25 preDeploytrueb. deploy
Perform actions during the deployment.
Example:
xxxxxxxxxx51deploymentDeployToProd2 strategy3 canary4 count25 deploytruec. routeTraffic
Divert traffic to the newly deployed version.
Example:
xxxxxxxxxx51deploymentDeployToProd2 strategy3 canary4 count25 routeTraffictrued. postRouteTraffic
Post-traffic monitoring after deploying changes.
Example:
xxxxxxxxxx51deploymentDeployToProd2 strategy3 canary4 count25 postRouteTraffictruee. on:failure
Run actions if deployment fails.
Example:
xxxxxxxxxx71deploymentDeployToProd2 strategy3 canary4 count25 on:failure6 steps7scriptecho "Sending failure notification"f. on:success
Run actions if deployment succeeds.
Example:
xxxxxxxxxx71deploymentDeployToProd2 strategy3 canary4 count25 on:success6 steps7scriptecho "Deployment completed successfully"Example of Complete Deployment Pipeline
xxxxxxxxxx221pipeline2 name'MyPipeline'3stages4stageBuild5 jobs6jobBuildJob7 steps8scriptecho "Building the project"9stageDeploy10 jobs11deploymentDeployToProd12 environment'Production'13 strategy14 canary15 count216 preDeploytrue17 deploytrue18 routeTraffictrue19 postRouteTraffictrue20 on:failure21 steps22scriptecho "Failure handling"Summary Table of Pipeline Structure in Azure DevOps
| Component | Description |
|---|---|
| Pipeline | Top-level structure encompassing stages and jobs. |
| Stage | Logical grouping of jobs. |
| Job | Group of steps executed on a single agent within a stage. |
| Steps | Individual actions or commands within a job. |
| Tasks | Predefined actions for tasks like building, deploying, or testing. |
| Deployment Strategy | Defines how deployments are rolled out (e.g., RunOnce, Rolling, Canary). |
| Lifecycle Hooks | Custom actions triggered during specific phases (preDeploy, deploy, routeTraffic, etc.). |






















Leave a Reply