Challenge - 5 Problems
Build Timeout Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Jenkins Pipeline: Timeout Behavior
What will be the output if the following Jenkins pipeline script runs and the 'sleep' step exceeds the timeout duration?
Jenkins
pipeline {
agent any
stages {
stage('Test Timeout') {
steps {
timeout(time: 1, unit: 'MINUTES') {
sleep time: 90, unit: 'SECONDS'
echo 'Completed sleep'
}
}
}
}
}Attempts:
2 left
💡 Hint
Consider what happens when a step runs longer than the timeout block allows.
✗ Incorrect
The 'timeout' step aborts the build if the enclosed steps exceed the specified time. Here, sleeping for 90 seconds exceeds the 1-minute timeout, causing the build to fail with a timeout error.
❓ Configuration
intermediate2:00remaining
Configuring Build Timeout in Jenkins Freestyle Job
Which configuration snippet correctly sets a build timeout of 10 minutes in a Jenkins freestyle job using the 'Build Timeout' plugin?
Attempts:
2 left
💡 Hint
Timeout is set in minutes, and failing the build on timeout is common.
✗ Incorrect
The 'timeoutMinutes' field expects the timeout duration in minutes. Setting 'failBuild' to true causes the build to fail if the timeout is reached. Option B correctly sets a 10-minute timeout and fails the build on timeout.
❓ Troubleshoot
advanced2:00remaining
Diagnosing Timeout Not Triggering in Jenkins Pipeline
A Jenkins pipeline uses the 'timeout' step set to 5 minutes, but the build runs for 10 minutes without aborting. What is the most likely cause?
Jenkins
pipeline {
agent any
stages {
stage('Long Task') {
steps {
timeout(time: 5, unit: 'MINUTES') {
sh 'sleep 600'
}
}
}
}
}Attempts:
2 left
💡 Hint
Think about how Jenkins interrupts running shell commands.
✗ Incorrect
The 'timeout' step can interrupt pipeline steps, but shell commands like 'sleep' may not respond to the interrupt signal properly, causing the timeout to not abort the build as expected.
🔀 Workflow
advanced2:00remaining
Implementing Timeout with Retry in Jenkins Pipeline
Which Jenkins pipeline snippet correctly retries a build stage up to 3 times if it times out after 2 minutes each attempt?
Attempts:
2 left
💡 Hint
Timeout should wrap the command inside the retry block to retry on timeout.
✗ Incorrect
Wrapping the 'timeout' step inside the 'retry' block ensures that if the timeout occurs, the stage is retried up to 3 times. Option A correctly places 'timeout' inside 'retry'.
✅ Best Practice
expert2:00remaining
Best Practice for Setting Build Timeout in Jenkins Declarative Pipeline
Which approach is the best practice to set a global build timeout of 15 minutes for all stages in a Jenkins declarative pipeline?
Attempts:
2 left
💡 Hint
Consider how to apply timeout globally in declarative pipelines.
✗ Incorrect
Using the 'options' directive with 'timeout' at the pipeline level applies the timeout globally to the entire build, which is cleaner and less error-prone than wrapping each stage individually.