Challenge - 5 Problems
Tools Directive Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Jenkins Tools Directive Usage Output
What is the output of this Jenkins pipeline snippet using the
tools directive?pipeline {
agent any
tools {
maven 'Maven_3.8.1'
}
stages {
stage('Build') {
steps {
sh 'mvn -version'
}
}
}
}Jenkins
pipeline {
agent any
tools {
maven 'Maven_3.8.1'
}
stages {
stage('Build') {
steps {
sh 'mvn -version'
}
}
}
}Attempts:
2 left
💡 Hint
The
tools directive sets up the specified tool version in the environment.✗ Incorrect
The
tools directive configures Jenkins to use the named Maven installation 'Maven_3.8.1'. The sh 'mvn -version' command then runs with that Maven version available, printing its version details.❓ Configuration
intermediate2:00remaining
Correct Tools Directive Syntax
Which Jenkins pipeline snippet correctly uses the
tools directive to set JDK 11 and Maven 3.6.3?Attempts:
2 left
💡 Hint
The tools directive uses Groovy method call syntax without colons or equals.
✗ Incorrect
The correct syntax uses method calls with space-separated strings. Semicolons are optional if each tool is on its own line.
❓ Troubleshoot
advanced2:00remaining
Troubleshooting Tools Directive Failure
A Jenkins pipeline with
What is the most likely cause?
tools { maven 'Maven_3.8.1' } fails with:ERROR: Maven tool 'Maven_3.8.1' is not configuredWhat is the most likely cause?
Attempts:
2 left
💡 Hint
Check Jenkins global tool configuration for the named tool installation.
✗ Incorrect
The tools directive requires the named tool to be configured in Jenkins global settings. If missing, Jenkins cannot set up the tool and errors out.
🔀 Workflow
advanced2:00remaining
Tools Directive Effect on Environment Variables
In a Jenkins pipeline using
tools { jdk 'JDK11' }, which environment variable is automatically set for the build steps?Attempts:
2 left
💡 Hint
The tools directive sets environment variables related to the tool used.
✗ Incorrect
When you specify a JDK in tools, Jenkins sets JAVA_HOME to that JDK's path for the build steps.
✅ Best Practice
expert2:00remaining
Best Practice for Using Tools Directive in Shared Libraries
You maintain a Jenkins shared library that runs builds requiring Maven. What is the best practice to ensure the
tools directive works correctly when used inside the shared library's pipeline code?Attempts:
2 left
💡 Hint
Consider how Jenkins processes the tools directive in pipeline and shared library contexts.
✗ Incorrect
The tools directive should be declared in the Jenkinsfile pipeline script to ensure Jenkins sets up tools properly. Shared libraries should not hardcode tool names to keep flexibility.