0
0
Jenkinsdevops~5 mins

Labels for agent selection in Jenkins - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of labels in Jenkins agent selection?
Labels help Jenkins identify and select the right agent (worker) to run a job based on the agent's capabilities or characteristics.
Click to reveal answer
beginner
How do you assign a label to a Jenkins agent?
In Jenkins, go to the agent's configuration page and enter the label(s) in the 'Labels' field. Multiple labels can be separated by spaces.
Click to reveal answer
intermediate
What happens if a Jenkins job specifies a label that no agent has?
The job will remain in the queue and wait until an agent with the specified label becomes available or the label is corrected.
Click to reveal answer
intermediate
How do you specify a label for agent selection in a Jenkins Pipeline script?
Use the 'agent' directive with 'label' inside the pipeline block, for example:
pipeline { agent { label 'linux' } stages { ... } }
Click to reveal answer
intermediate
Can a Jenkins agent have multiple labels? Why is this useful?
Yes, an agent can have multiple labels. This allows flexible job assignment because jobs can request any one of the labels that match the agent's capabilities.
Click to reveal answer
What is the main use of labels in Jenkins agent selection?
ATo configure Jenkins plugins
BTo name the Jenkins job
CTo set job build triggers
DTo identify which agent should run a job
Where do you assign labels to a Jenkins agent?
AIn the Jenkins system logs
BIn the Jenkins global settings
CIn the agent's configuration page
DInside the job's build steps
What happens if no agent matches the label specified in a Jenkins job?
AThe job waits in the queue until an agent is available
BThe job runs on the master node
CThe job is canceled automatically
DThe job runs on any available agent
How do you specify an agent label in a Jenkins Pipeline script?
Aagent { label 'labelName' }
Bnode('labelName') { }
Cstage('labelName') { }
Dbuild('labelName')
Why might an agent have multiple labels?
ATo confuse Jenkins
BTo allow jobs with different label requirements to run on it
CTo increase build speed
DTo reduce disk space usage
Explain how Jenkins uses labels to select agents for running jobs.
Think about how Jenkins finds the right worker for a task.
You got /4 concepts.
    Describe how to assign and use labels in a Jenkins Pipeline script.
    Focus on both the agent setup and pipeline syntax.
    You got /3 concepts.