Challenge - 5 Problems
Node and Stage Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of Jenkins Pipeline with nested node blocks
What will be the output of this Jenkins pipeline snippet when executed?
Jenkins
pipeline {
agent none
stages {
stage('Build') {
steps {
script {
node('linux') {
echo 'Inside first node'
node('windows') {
echo 'Inside nested node'
}
}
}
}
}
}
}Attempts:
2 left
💡 Hint
Think about how nested node blocks execute in Jenkins pipelines.
✗ Incorrect
In Jenkins declarative pipelines, 'node' blocks are not allowed inside 'steps' blocks, whether single or nested. This is scripted DSL syntax and will cause a 'No such DSL method node' error.
🧠 Conceptual
intermediate1:30remaining
Purpose of 'agent none' in Jenkins pipeline
What is the main purpose of using
agent none at the top level of a Jenkins declarative pipeline?Attempts:
2 left
💡 Hint
Consider how agent allocation works when you want different stages on different nodes.
✗ Incorrect
Using 'agent none' disables automatic agent allocation at the pipeline level, allowing each stage to specify its own node or agent block.
❓ Troubleshoot
advanced2:30remaining
Why does this Jenkins pipeline fail with 'No such DSL method node' error?
Given this pipeline snippet, why does Jenkins report 'No such DSL method node' error?
pipeline {
agent any
stages {
stage('Test') {
steps {
node('linux') {
echo 'Running tests'
}
}
}
}
}Attempts:
2 left
💡 Hint
Check the allowed syntax inside declarative pipeline 'steps' blocks.
✗ Incorrect
In declarative pipelines, 'node' blocks are not allowed inside 'steps'. Instead, use 'agent' at stage level or script blocks for scripted syntax.
🔀 Workflow
advanced3:00remaining
Correct stage and node usage for parallel builds
You want to run two builds in parallel on different nodes: one on 'linux' and one on 'windows'. Which pipeline snippet correctly achieves this?
Jenkins
pipeline {
agent none
stages {
stage('Parallel Builds') {
parallel {
'Linux Build': {
node('linux') {
echo 'Building on Linux'
}
},
'Windows Build': {
node('windows') {
echo 'Building on Windows'
}
}
}
}
}
}Attempts:
2 left
💡 Hint
Think about how parallel stages and agents work in declarative pipelines.
✗ Incorrect
Declarative pipelines support parallel stages, but 'agent' cannot be used inside parallel branches/stages. Branches share the parent stage's agent. Use scripted 'node' {} inside parallel closures for different agents.
✅ Best Practice
expert3:00remaining
Best practice for using node blocks in Jenkins scripted pipeline
In a scripted Jenkins pipeline, what is the best practice for using
node blocks to optimize resource usage and avoid unnecessary workspace allocation?Attempts:
2 left
💡 Hint
Consider workspace allocation and agent usage costs.
✗ Incorrect
Using a single node block reduces overhead by allocating workspace once and reusing it, improving efficiency and reducing resource consumption.