0
0
Jenkinsdevops~20 mins

Labels for agent selection in Jenkins - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Label Mastery in Jenkins
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
Agent 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"
      }
    }
  }
}
AThe pipeline runs on any agent that has either 'linux' or 'docker' label assigned.
BThe pipeline fails to start due to invalid label syntax.
CThe pipeline runs only on agents that have both 'linux' and 'docker' labels assigned.
DThe pipeline runs on the first available agent regardless of labels.
Attempts:
2 left
💡 Hint
Think about how Jenkins interprets label expressions with && operator.
🧠 Conceptual
intermediate
1:30remaining
Understanding label expressions for agent selection
Which label expression correctly selects agents that have the label 'windows' but not the label 'test'?
Awindows && !test
Bwindows || !test
C!windows && test
D!windows || test
Attempts:
2 left
💡 Hint
Use logical AND and NOT operators to combine labels.
Troubleshoot
advanced
2:00remaining
Troubleshooting 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?
AThe Jenkins master node is offline.
BThe label expression syntax is incorrect and causes a parsing error.
CThe pipeline requires a Windows agent but labels specify Linux agents.
DNo agent has both 'docker' and 'gpu' labels assigned.
Attempts:
2 left
💡 Hint
Check the labels assigned to your agents carefully.
🔀 Workflow
advanced
1:30remaining
Configuring 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?
Amac && linux
Bmac || linux
Cmac, linux
Dmac linux
Attempts:
2 left
💡 Hint
Use logical OR operator to select agents with either label.
Best Practice
expert
2:30remaining
Best 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?
AAssign multiple specific labels like 'linux', 'docker', 'gpu' to each agent based on capabilities.
BAssign a single generic label like 'build-agent' to all agents regardless of capabilities.
CUse only OS labels like 'windows' or 'linux' and ignore capabilities.
DDo not use labels; rely on agent names for selection.
Attempts:
2 left
💡 Hint
Think about how pipelines can select agents based on multiple criteria.