0
0
Jenkinsdevops~10 mins

Blue-green deployment pattern in Jenkins - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Blue-green deployment pattern
Start with Blue environment live
Deploy new version to Green environment
Test Green environment
Switch traffic to Green
Green is live
Old Blue environment idle
This flow shows how traffic switches between two identical environments (Blue and Green) to deploy updates safely.
Execution Sample
Jenkins
pipeline {
  stages {
    stage('Deploy Green') {
      steps {
        echo 'Deploying to Green environment'
      }
    }
    stage('Switch Traffic') {
      steps {
        echo 'Switching traffic to Green'
      }
    }
  }
}
A Jenkins pipeline that deploys to the Green environment and then switches traffic to it.
Process Table
StepActionEnvironment StateTraffic RoutingResult
1Start with Blue liveBlue: live, Green: idleTraffic -> BlueSystem serving users from Blue
2Deploy new version to GreenBlue: live, Green: deployingTraffic -> BlueGreen environment updated, Blue still live
3Test Green environmentBlue: live, Green: readyTraffic -> BlueGreen passes tests, ready for switch
4Switch traffic to GreenBlue: live, Green: liveTraffic -> GreenUsers now served by Green
5Blue environment idleBlue: idle, Green: liveTraffic -> GreenBlue environment ready for next update
💡 Traffic switched to Green, Blue environment is idle, deployment complete
Status Tracker
VariableStartAfter Step 2After Step 3After Step 4Final
Blue environment stateliveliveliveidleidle
Green environment stateidledeployingreadylivelive
Traffic routingBlueBlueBlueGreenGreen
Key Moments - 3 Insights
Why do we keep Blue environment live while deploying to Green?
Because Blue serves users without interruption during Green deployment, ensuring no downtime (see execution_table step 2).
What happens if Green environment tests fail?
Traffic stays on Blue, and Green deployment is rolled back or fixed before switching (implied by execution_table step 3 branching).
Why is Blue environment kept idle after switching traffic?
To have a ready fallback environment for quick rollback if needed (execution_table step 5).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, at which step does traffic switch from Blue to Green?
AStep 4
BStep 3
CStep 2
DStep 5
💡 Hint
Check the 'Traffic Routing' column in execution_table rows
According to variable_tracker, what is the state of the Blue environment after step 4?
Alive
Bidle
Cdeploying
Dready
💡 Hint
Look at 'Blue environment state' column after 'After Step 4' in variable_tracker
If the Green environment fails testing, what would happen to traffic routing?
ASwitch to Green anyway
BTraffic stops completely
CTraffic remains on Blue
DTraffic switches to a new environment
💡 Hint
Refer to key_moments about test failure and execution_table step 3
Concept Snapshot
Blue-green deployment uses two identical environments: Blue (live) and Green (idle).
Deploy updates to Green while Blue serves users.
Test Green, then switch traffic to Green if tests pass.
Blue becomes idle, ready for rollback.
This ensures zero downtime and quick recovery.
Full Transcript
Blue-green deployment pattern uses two environments to avoid downtime. Initially, Blue is live serving users. The new version is deployed to Green while Blue remains live. After deployment, Green is tested. If tests pass, traffic switches to Green, making it live. Blue then becomes idle, ready for the next update or rollback. This method ensures users experience no downtime and allows quick fallback if needed.