Challenge - 5 Problems
Label Mastery in Jenkins
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediateAgent selection with label in Jenkins pipeline
What will be the output or behavior when running this Jenkins pipeline snippet?
Jenkins
pipeline {
agent { label 'linux && docker' }
stages {
stage('Build') {
steps {
echo "Running on agent with linux and docker labels"
}
}
}
}Attempts:
2 left
💡 Hint
Think about how Jenkins interprets label expressions with && operator.
✗ Incorrect
Using 'label "linux && docker"' means the agent must have both labels 'linux' and 'docker' to run the pipeline. It is a logical AND condition.
🧠 Conceptual
intermediateUnderstanding label expressions for agent selection
Which label expression correctly selects agents that have the label 'windows' but not the label 'test'?
Attempts:
2 left
💡 Hint
Use logical AND and NOT operators to combine labels.
✗ Incorrect
The expression 'windows && !test' means select agents that have 'windows' label and do not have 'test' label.
❓ Troubleshoot
advancedTroubleshooting agent label mismatch in Jenkins
A Jenkins pipeline with agent label 'docker && gpu' fails to find a suitable agent. Which is the most likely cause?
Attempts:
2 left
💡 Hint
Check the labels assigned to your agents carefully.
✗ Incorrect
If no agent has both 'docker' and 'gpu' labels, Jenkins cannot find a matching agent to run the pipeline.
🔀 Workflow
advancedConfiguring Jenkins pipeline to run on multiple label options
You want a Jenkins pipeline to run on agents that have either 'mac' or 'linux' label. Which agent label expression should you use?
Attempts:
2 left
💡 Hint
Use logical OR operator to select agents with either label.
✗ Incorrect
The expression 'mac || linux' means the pipeline can run on agents with 'mac' label or 'linux' label.
✅ Best Practice
expertBest practice for labeling Jenkins agents for flexible selection
Which approach is best to label Jenkins agents to allow pipelines to select agents flexibly by OS and capability?
Attempts:
2 left
💡 Hint
Think about how pipelines can select agents based on multiple criteria.
✗ Incorrect
Assigning multiple specific labels allows pipelines to select agents flexibly by combining labels for OS and capabilities.
