0
0
Jenkinsdevops~20 mins

Pipeline utility functions in Jenkins - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Pipeline Utility Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2: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}"
        }
      }
    }
  }
}
AJenkins
Bversion
C2.0
Dnull
Attempts:
2 left
💡 Hint
The readYaml step parses YAML text into a map. Access keys by their names.
🧠 Conceptual
intermediate
1:30remaining
Purpose of stash and unstash in Jenkins Pipeline
What is the main purpose of using stash and unstash steps in a Jenkins pipeline?
ATo clean the workspace before starting a new build
BTo permanently store build artifacts on the Jenkins master
CTo send notifications to users after a build completes
DTo save files temporarily and retrieve them in another stage or node
Attempts:
2 left
💡 Hint
Think about sharing files between different parts of the pipeline.
🔀 Workflow
advanced
2: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:
A4,2,3,1
B4,3,2,1
C3,4,2,1
D2,4,3,1
Attempts:
2 left
💡 Hint
Think about the logical flow: get code, build, save output, then clean.
Troubleshoot
advanced
2: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?
AThe pipeline utility steps plugin is not installed or not loaded
BThe pipeline syntax is missing a <code>script</code> block
CThe Jenkins agent does not have internet access
DThe JSON file path is incorrect
Attempts:
2 left
💡 Hint
MissingMethodException usually means the method is unknown to Jenkins.
Best Practice
expert
3: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?
AUse environment variables set globally on the Jenkins master
BHardcode secrets directly in pipeline scripts for easy access
CStore secrets in Jenkins credentials and access them via <code>withCredentials</code> block
DSave secrets in plain text files in the workspace and read them with <code>readFile</code>
Attempts:
2 left
💡 Hint
Think about security and avoiding exposure of secrets.