Challenge - 5 Problems
JDK Configuration Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Jenkins JDK Configuration Verification
You have configured a JDK installation named 'jdk11' in Jenkins global tools. Which command run on a Jenkins agent will confirm the JDK version used by Jenkins?
Jenkins
$JAVA_HOME/bin/java -version
Attempts:
2 left
💡 Hint
Check the JAVA_HOME environment variable set by Jenkins for the configured JDK.
✗ Incorrect
Jenkins sets JAVA_HOME to the configured JDK path. Running '$JAVA_HOME/bin/java -version' ensures you check the exact JDK Jenkins uses, regardless of system defaults.
❓ Configuration
intermediate2:00remaining
Setting Up Multiple JDKs in Jenkins
You want to configure two JDK versions, JDK 8 and JDK 17, in Jenkins global tools. Which configuration snippet correctly defines both JDKs in Jenkins' config.xml?
Attempts:
2 left
💡 Hint
Each JDK must be a separate element at the same level.
✗ Incorrect
Jenkins expects each JDK to be defined as a separate element with and tags. Option A correctly shows two sibling elements.
🔀 Workflow
advanced3:00remaining
Using Multiple JDKs in Jenkins Pipeline
In a Jenkins pipeline, you want to run one stage with JDK 8 and another with JDK 17. Which pipeline snippet correctly switches JDK versions for each stage?
Jenkins
pipeline {
agent any
stages {
stage('Build with JDK 8') {
steps {
// JDK 8 steps here
}
}
stage('Build with JDK 17') {
steps {
// JDK 17 steps here
}
}
}
}Attempts:
2 left
💡 Hint
Use withEnv and tool step to switch JDK versions inside stages.
✗ Incorrect
Option A correctly uses withEnv and the tool step to set JAVA_HOME and PATH for each stage, allowing different JDKs per stage. Other options misuse tools block or hardcode paths.
❓ Troubleshoot
advanced2:00remaining
Jenkins JDK Configuration Not Applied
You configured JDK 11 in Jenkins global tools and selected it in a freestyle job, but the build still uses the system default JDK. What is the most likely cause?
Attempts:
2 left
💡 Hint
Check if the JDK path is valid on the agent machine.
✗ Incorrect
If 'Install automatically' is not enabled, Jenkins expects the JDK path to exist on the agent. If the path is wrong or missing, Jenkins falls back to system default JDK.
✅ Best Practice
expert3:00remaining
Best Practice for Managing JDK Versions in Jenkins
Which approach is best to ensure consistent JDK versions across multiple Jenkins agents in a large environment?
Attempts:
2 left
💡 Hint
Automatic installation ensures uniformity and reduces manual errors.
✗ Incorrect
Enabling 'Install automatically' in Jenkins global tools lets Jenkins manage JDK installations uniformly across agents, ensuring consistent versions and reducing manual setup errors.