Understanding Continuous Delivery vs Continuous Deployment with Jenkins
📖 Scenario: You are working as a DevOps engineer at a software company. Your team wants to automate the process of delivering software updates to users. You will learn the difference between Continuous Delivery and Continuous Deployment using Jenkins, a popular automation tool.
🎯 Goal: Build a simple Jenkins pipeline script that demonstrates the concepts of Continuous Delivery and Continuous Deployment by controlling when the software is automatically released to users.
📋 What You'll Learn
Create a Jenkins pipeline script with a variable to control deployment mode
Add a stage to build the software
Add a stage to deploy the software only if in Continuous Deployment mode
Print messages to show whether deployment is automatic or manual
💡 Why This Matters
🌍 Real World
Software teams use Jenkins pipelines to automate building and deploying applications. Understanding Continuous Delivery vs Continuous Deployment helps teams decide when to release software automatically or with manual checks.
💼 Career
DevOps engineers and automation specialists often configure Jenkins pipelines to implement Continuous Delivery or Continuous Deployment strategies, improving software release speed and reliability.
Progress0 / 4 steps
1
Create a Jenkins pipeline with a deployment mode variable
Create a Jenkins pipeline script and define a variable called deploymentMode with the value "Continuous Delivery".
Jenkins
Hint
Use the environment block to define the deploymentMode variable.
2
Add a build stage to the Jenkins pipeline
Add a stage called Build inside the stages block that prints "Building the software...".
Jenkins
Hint
Use stage('Build') and inside steps use echo to print the message.
3
Add a deploy stage that runs only in Continuous Deployment mode
Add a stage called Deploy that runs only if deploymentMode equals "Continuous Deployment". Inside, print "Automatically deploying the software...". Use when { expression { deploymentMode == 'Continuous Deployment' } } to control this.
Jenkins
Hint
Use the when block with an expression to check deploymentMode.
4
Print the deployment mode and explain the difference
Add a post block with always that prints "Deployment mode is: " + deploymentMode and if deploymentMode is "Continuous Delivery", also print "Deployment requires manual approval." Otherwise, print "Deployment is automatic."
Jenkins
Hint
Use the post block with always and a script block to run conditional echo commands.
Practice
(1/5)
1. What is the main difference between Continuous Delivery and Continuous Deployment?
easy
A. Continuous Delivery only builds code, Continuous Deployment only tests code.
B. Continuous Delivery deploys every change automatically, Continuous Deployment requires manual approval.
C. Continuous Delivery requires manual approval before production deployment, Continuous Deployment does not.
D. Continuous Delivery and Continuous Deployment are exactly the same.
Solution
Step 1: Understand Continuous Delivery
Continuous Delivery automates preparing the software for release but waits for a manual step to deploy to production.
Step 2: Understand Continuous Deployment
Continuous Deployment automates the entire process, including automatic deployment to production without manual approval.
Final Answer:
Continuous Delivery requires manual approval before production deployment, Continuous Deployment does not. -> Option C
Quick Check:
Manual approval = Continuous Delivery [OK]
Hint: Manual step means Continuous Delivery, no manual means Continuous Deployment [OK]
Common Mistakes:
Confusing which process needs manual approval
Thinking both deploy automatically
Mixing build and deploy steps
2. Which Jenkins pipeline step is typically used to pause for manual approval in Continuous Delivery?
easy
A. input
B. deploy
C. build
D. test
Solution
Step 1: Identify Jenkins step for manual pause
The input step in Jenkins pipeline pauses the pipeline and waits for user approval.
Step 2: Confirm other steps roles
deploy runs deployment, build compiles code, test runs tests, none pause for approval.
Final Answer:
input -> Option A
Quick Check:
Manual approval step = input [OK]
Hint: Pause for approval uses 'input' step in Jenkins [OK]
Common Mistakes:
Choosing deploy as manual step
Confusing build or test with approval
Not knowing Jenkins pipeline steps
3. Given this Jenkins pipeline snippet for Continuous Delivery:
stage('Deploy to Prod') {
steps {
input 'Approve deployment?'
sh 'deploy.sh'
}
}
What happens when this pipeline reaches the Deploy to Prod stage?
medium
A. The pipeline pauses and waits for manual approval before running deployment.
B. The pipeline fails with a syntax error.
C. The pipeline skips deployment and ends.
D. The deployment script runs immediately without pause.
Solution
Step 1: Analyze the input step in the stage
The input 'Approve deployment?' pauses the pipeline and waits for a user to approve before continuing.
Step 2: Understand what happens after approval
After approval, the shell script deploy.sh runs to deploy the application.
Final Answer:
The pipeline pauses and waits for manual approval before running deployment. -> Option A
Quick Check:
input step causes pause = The pipeline pauses and waits for manual approval before running deployment. [OK]
Hint: input step pauses pipeline until approval [OK]
Common Mistakes:
Assuming deploy runs immediately
Thinking pipeline skips deployment
Confusing syntax error with input step
4. You have a Jenkins pipeline intended for Continuous Deployment but it includes this code: