A. Incorrect agent block syntax, should be agent { label 'docker' }
B. Missing quotes around label name
C. Agent directive cannot use label
D. Pipeline missing stages block
Solution
Step 1: Review agent block syntax
The label value must be enclosed in quotes, like label 'docker'.
Step 2: Identify syntax error
The snippet has label docker without quotes, causing a syntax error as docker is treated as an undefined variable.
Final Answer:
Missing quotes around label name -> Option B
Quick Check:
Agent block syntax must be exact [OK]
Hint: Agent block must be exactly agent { label 'name' } [OK]
Common Mistakes:
Misplacing braces or indentation
Using agent label without braces
Confusing agent label with docker agent syntax
5. You want a Jenkins pipeline that does not allocate any agent by default but runs the Deploy stage on a Docker container with image nginx:latest. Which pipeline snippet correctly achieves this?
hard
A. pipeline {
agent any
stages {
stage('Deploy') {
agent none
steps {
echo 'Deploying with nginx container'
}
}
}
}