0
0
Jenkinsdevops~5 mins

Tools directive in Jenkins - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the tools directive in Jenkins pipelines?
The tools directive tells Jenkins which software tools (like JDK, Maven, or Gradle) to install and use during the pipeline run.
Click to reveal answer
beginner
How do you specify a JDK version using the tools directive in a Jenkins pipeline?
You specify it like this:<br>
tools {<br>  jdk 'JDK11'<br>}
<br>This tells Jenkins to use the JDK named 'JDK11' configured in Jenkins.
Click to reveal answer
intermediate
Can the tools directive install multiple tools at once?
Yes, you can list multiple tools inside the tools block, for example:<br>
tools {<br>  jdk 'JDK11'<br>  maven 'Maven3'<br>}
Click to reveal answer
intermediate
What happens if the tool specified in the tools directive is not installed on the Jenkins agent?
Jenkins will automatically download and install the specified tool version on the agent before running the pipeline steps.
Click to reveal answer
beginner
Where do you configure the tool versions that can be used in the tools directive?
Tool versions are configured in Jenkins global configuration under 'Global Tool Configuration'. This is where you define names like 'JDK11' or 'Maven3'.
Click to reveal answer
What does the Jenkins tools directive do in a pipeline?
ADefines environment variables for the pipeline
BSpecifies software tools to install and use during the build
CRuns shell commands on the agent
DSets pipeline timeout values
How do you specify Maven version 'Maven3' in the tools directive?
Atools { maven 'Maven3' }
Btools { mavenVersion 'Maven3' }
Ctools { mavenVersion = 'Maven3' }
Dtools { maven = 'Maven3' }
If a tool is not installed on the Jenkins agent, what happens when specified in tools?
AAgent restarts
BPipeline fails immediately
CJenkins skips the tool
DJenkins installs it automatically
Where do you define the names like 'JDK11' used in the tools directive?
AGlobal Tool Configuration in Jenkins settings
BPipeline script
CAgent machine environment variables
DJenkinsfile workspace
Can you specify multiple tools in one tools block?
AOnly if they are the same type
BNo, only one tool per block
CYes, list them inside the block
DOnly if they are installed on the agent
Explain how the Jenkins tools directive helps manage software dependencies in a pipeline.
Think about how Jenkins prepares the environment for your build.
You got /4 concepts.
    Describe the steps to configure and use a new JDK version in Jenkins pipelines using the tools directive.
    Start from Jenkins settings, then pipeline usage.
    You got /4 concepts.