0
0
Jenkinsdevops~10 mins

Canary deployment pattern in Jenkins - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Canary deployment pattern
Start Deployment
Deploy Canary Version
Monitor Canary
Promote
Deploy Full
End Deployment
This flow shows deploying a small subset (canary), monitoring it, then either promoting to full or rolling back based on results.
Execution Sample
Jenkins
pipeline {
  agent any
  parameters {
    booleanParam(name: 'canaryOk', defaultValue: false, description: 'Indicates if canary deployment is healthy')
  }
  stages {
    stage('Deploy Canary') {
      steps { echo 'Deploying canary version' }
    }
    stage('Monitor Canary') {
      steps { echo 'Monitoring canary health' }
    }
    stage('Promote or Rollback') {
      steps {
        script {
          if (params.canaryOk) {
            echo 'Promoting to full deployment'
          } else {
            echo 'Rolling back canary deployment'
          }
        }
      }
    }
  }
}
A Jenkins pipeline that deploys a canary, monitors it, then promotes or rolls back based on a parameter.
Process Table
StepActionConditionResultOutput
1Deploy Canary stage runsN/ACanary deployedDeploying canary version
2Monitor Canary stage runsN/ACanary monitoredMonitoring canary health
3Check canaryOk parametercanaryOk == truePromote full deploymentPromoting to full deployment
4End pipelineN/ASuccessPipeline completed
5Alternative checkcanaryOk == falseRollback canaryRolling back canary deployment
6End pipelineN/AFailure handledPipeline completed with rollback
💡 Pipeline ends after promotion or rollback based on canaryOk parameter.
Status Tracker
VariableStartAfter Step 3Final
params.canaryOkundefinedtrue or false (set externally)true or false (used to decide)
Key Moments - 3 Insights
Why do we deploy only a small part of the system first?
Deploying a small canary limits risk. If issues occur (see step 5 in execution_table), we rollback quickly without affecting all users.
What happens if the canary monitoring fails?
If monitoring shows problems (canaryOk == false), the pipeline rolls back the canary (step 5), preventing faulty code from reaching full deployment.
How does the pipeline decide to promote or rollback?
It uses the parameter 'canaryOk' checked in step 3. True promotes full deployment, false triggers rollback.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what output appears when the canary is healthy?
APromoting to full deployment
BDeploying canary version
CRolling back canary deployment
DMonitoring canary health
💡 Hint
Check row 3 in execution_table where canaryOk == true.
At which step does the pipeline decide to rollback the canary?
AStep 3
BStep 5
CStep 2
DStep 1
💡 Hint
Look for rollback action in execution_table rows.
If the canaryOk parameter is false, what is the final pipeline output?
APipeline completed
BPromoting to full deployment
CPipeline completed with rollback
DDeploying canary version
💡 Hint
See the last row in execution_table for canaryOk == false.
Concept Snapshot
Canary deployment pattern in Jenkins:
- Deploy a small subset (canary) first
- Monitor canary health
- If healthy, promote to full deployment
- If issues, rollback canary
- Use parameters to control flow
- Minimizes risk by limiting exposure
Full Transcript
The canary deployment pattern in Jenkins starts by deploying a small part of the new version called the canary. Then the system monitors this canary for any problems. If the canary is healthy, the pipeline promotes the deployment to all users. If problems are detected, the pipeline rolls back the canary to avoid impacting everyone. This decision is controlled by a parameter called canaryOk. This approach reduces risk by testing changes on a small scale before full rollout.