Challenge - 5 Problems
Pipeline Utility Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of readYaml in Jenkins Pipeline
Given the following Jenkins pipeline snippet, what is the output of the
echo step?Jenkins
pipeline {
agent any
stages {
stage('Read YAML') {
steps {
script {
def config = readYaml text: '''\nname: Jenkins\nversion: 2.0\n'''
echo "${config.name}"
}
}
}
}
}Attempts:
2 left
💡 Hint
The readYaml step parses YAML text into a map. Access keys by their names.
✗ Incorrect
The readYaml step converts the YAML string into a map with keys 'name' and 'version'. Accessing config.name returns 'Jenkins'.
🧠 Conceptual
intermediate1:30remaining
Purpose of stash and unstash in Jenkins Pipeline
What is the main purpose of using
stash and unstash steps in a Jenkins pipeline?Attempts:
2 left
💡 Hint
Think about sharing files between different parts of the pipeline.
✗ Incorrect
Stash saves files temporarily so they can be unstashed later in another stage or node, enabling file sharing across pipeline steps.
🔀 Workflow
advanced2:30remaining
Correct order of steps to archive artifacts and clean workspace
Arrange the following Jenkins pipeline steps in the correct order to archive build artifacts and then clean the workspace:
Attempts:
2 left
💡 Hint
Think about the logical flow: get code, build, save output, then clean.
✗ Incorrect
First checkout code (4), then build (3), archive artifacts (2), and finally clean workspace (1).
❓ Troubleshoot
advanced2:00remaining
Error caused by missing library in pipeline utility step
A Jenkins pipeline uses
readJSON from the pipeline utility steps plugin but fails with groovy.lang.MissingMethodException. What is the most likely cause?Attempts:
2 left
💡 Hint
MissingMethodException usually means the method is unknown to Jenkins.
✗ Incorrect
If the plugin providing readJSON is missing, Jenkins cannot find the method, causing this error.
✅ Best Practice
expert3:00remaining
Best practice for handling secrets with pipeline utility functions
Which approach is the safest and recommended way to handle secrets in Jenkins pipelines when using pipeline utility functions?
Attempts:
2 left
💡 Hint
Think about security and avoiding exposure of secrets.
✗ Incorrect
Using Jenkins credentials with withCredentials securely injects secrets only during needed steps without exposing them in logs or code.