What does the `tools` directive do?
BeginnerConceptDeclarative pipeline syntax
Answer
It installs (if needed) and puts on PATH a tool configured globally under Tools, such as a JDK, Maven or NodeJS installation.
tools { jdk 'temurin-21'; maven 'maven-3.9' }
The name must match the global tool configuration (often set via JCasC). With container-based agents we usually skip tools and pick an image that already contains the right versions, which is faster and reproducible.
More on Declarative pipeline syntax
What is the minimum valid declarative pipeline?BeginnerWhat agent types exist in declarative pipelines?IntermediateWhen do you use `agent none` at the top level?IntermediateHow do nested sequential stages work and why are they useful?IntermediateList the `post` conditions and when each fires.IntermediateWhat are the most useful `when` conditions?Intermediate