0
0
Jenkinsdevops~20 mins

Canary deployment pattern in Jenkins - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Canary Deployment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding Canary Deployment Purpose

What is the main goal of using a canary deployment in a Jenkins pipeline?

ATo rollback all previous versions automatically
BTo deploy new code to all users at once to save time
CTo test new code on a small subset of users before full rollout
DTo run all tests in parallel before deployment
Attempts:
2 left
💡 Hint

Think about minimizing risk when releasing new software.

💻 Command Output
intermediate
1:30remaining
Jenkins Pipeline Stage Output for Canary Deployment

Given this Jenkins pipeline snippet for canary deployment, what will be the output of the Deploy Canary stage if the deployment succeeds?

Jenkins
stage('Deploy Canary') {
  steps {
    echo 'Deploying to 10% of users'
    sh 'kubectl apply -f canary-deployment.yaml'
    echo 'Canary deployment successful'
  }
}
ADeploying to 10% of users\nCanary deployment successful
BDeploying to 100% of users\nCanary deployment successful
CError: Deployment failed
DDeploying to 10% of users\nDeployment failed
Attempts:
2 left
💡 Hint

Look at the echo statements and the deployment percentage.

Configuration
advanced
2:30remaining
Configuring Jenkinsfile for Canary Deployment Rollback

Which Jenkinsfile snippet correctly implements a rollback step if the canary deployment test fails?

A
stage('Canary Test') {
  steps {
    script {
      if (!sh(script: 'run_canary_tests.sh', returnStatus: true) == 0) {
        sh 'kubectl rollout undo deployment/my-app-canary'
      }
    }
  }
}
B
stage('Canary Test') {
  steps {
    script {
      if (sh(script: 'run_canary_tests.sh', returnStatus: true) != 0) {
        sh 'kubectl rollout undo deployment/my-app-canary'
      }
    }
  }
}
C
stage('Canary Test') {
  steps {
    script {
      if (sh(script: 'run_canary_tests.sh', returnStatus: false) != 0) {
        sh 'kubectl rollout undo deployment/my-app-canary'
      }
    }
  }
}
D
stage('Canary Test') {
  steps {
    script {
      if (sh(script: 'run_canary_tests.sh') == 0) {
        sh 'kubectl rollout undo deployment/my-app-canary'
      }
    }
  }
}
Attempts:
2 left
💡 Hint

Check how the shell command status is checked and when rollback should happen.

🔀 Workflow
advanced
2:00remaining
Order of Steps in a Canary Deployment Pipeline

Arrange the following steps in the correct order for a Jenkins pipeline implementing a canary deployment:

  • Run canary tests
  • Deploy to full production
  • Deploy to canary subset
  • Monitor canary metrics
A2,1,3,4
B1,3,2,4
C3,1,2,4
D1,2,3,4
Attempts:
2 left
💡 Hint

Think about deploying first, then testing and monitoring before full rollout.

Troubleshoot
expert
2:30remaining
Diagnosing Jenkins Canary Deployment Failure

In a Jenkins pipeline, the canary deployment stage runs but the new version is not serving traffic. Which of the following is the most likely cause?

AThe canary deployment manifest has the wrong selector labels, so traffic is not routed to the new pods
BThe Jenkinsfile syntax is incorrect, causing the deployment to fail
CThe rollback command was triggered prematurely
DThe Jenkins agent does not have permission to run shell commands
Attempts:
2 left
💡 Hint

Consider why new pods might not receive traffic despite successful deployment.