Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to run the Jenkins pipeline on an agent with the label 'linux'.
Jenkins
pipeline {
agent { label '[1]' }
stages {
stage('Build') {
steps {
echo 'Building on Linux agent'
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a label that does not exist on any agent.
Misspelling the label name.
✗ Incorrect
The label 'linux' selects agents tagged with 'linux' to run the pipeline.
2fill in blank
mediumComplete the code to run the Jenkins pipeline on an agent with the label 'docker'.
Jenkins
pipeline {
agent { label '[1]' }
stages {
stage('Test') {
steps {
echo 'Running tests on Docker agent'
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Docker' with uppercase D instead of 'docker'.
Selecting a label that does not exist.
✗ Incorrect
The label 'docker' selects agents that have Docker installed or are tagged accordingly.
3fill in blank
hardFix the error in the Jenkins pipeline to correctly select an agent with the label 'windows'.
Jenkins
pipeline {
agent { label '[1]' }
stages {
stage('Deploy') {
steps {
echo 'Deploying on Windows agent'
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase 'Windows' which does not match the label.
Using shorthand labels like 'win' that are not defined.
✗ Incorrect
Labels are case-sensitive; 'windows' in lowercase matches the agent label correctly.
4fill in blank
hardFill both blanks to run the pipeline on an agent with label 'linux' and specify the stage name as 'Build'.
Jenkins
pipeline {
agent { label '[1]' }
stages {
stage('[2]') {
steps {
echo 'Building project'
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up stage names with labels.
Using incorrect labels like 'windows' for a Linux agent.
✗ Incorrect
The agent label is 'linux' and the stage name is 'Build' as required.
5fill in blank
hardFill all three blanks to run the pipeline on an agent with label 'docker', name the stage 'Test', and print 'Running tests'.
Jenkins
pipeline {
agent { label '[1]' }
stages {
stage('[2]') {
steps {
echo '[3]'
}
}
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong labels like 'linux' instead of 'docker'.
Incorrect stage names or echo messages.
✗ Incorrect
The agent label is 'docker', the stage is named 'Test', and the echo prints 'Running tests'.