Blue-green deployment pattern
📖 Scenario: You work as a DevOps engineer managing a web application deployment. To avoid downtime during updates, you want to use the blue-green deployment pattern. This means you have two identical environments: blue and green. Only one environment serves live traffic at a time. When deploying a new version, you update the inactive environment, then switch traffic to it.
🎯 Goal: Build a Jenkins pipeline script that defines two environments blue and green, sets the active environment, deploys the new version to the inactive environment, and switches traffic to it.
📋 What You'll Learn
Create a variable
environments with values ['blue', 'green']Create a variable
activeEnv set to 'blue'Write a function
getInactiveEnv that returns the environment not currently activePrint the inactive environment, deploy to it, then switch
activeEnv to itPrint the new active environment after switching
💡 Why This Matters
🌍 Real World
Blue-green deployment is used in real companies to update applications without downtime by switching traffic between two identical environments.
💼 Career
Understanding this pattern helps DevOps engineers automate safe deployments and reduce risks during updates.
Progress0 / 4 steps