title: Why is the mvn command not found in this declarative jenkins pipeline script?
body: <p>I got this example from <a href="https://jenkins.io/doc/book/pipeline/syntax/#tools" rel="nofollow noreferrer">https://jenkins.io/doc/book/pipeline/syntax/#tools</a></p>
  
  <p>Pipeline Script:</p>
  
  <pre><code>pipeline {
      agent any
      tools {
          maven 'apache-maven-3.3.9' 
      }
      stages {
          stage('Example') {
              steps {
                  sh 'mvn --version'
              }
          }
      }
  }
  </code></pre>
  
  <p>apache-maven-3.3.9 is defined in my Global Tool Configuration.</p>
  
  <p>The output of the script however is</p>
  
  <pre><code>Started by user *************
  Running in Durability level: MAX_SURVIVABILITY
  [Pipeline] node
  Running on SRV-CI-MADE-UNIX in /home/jenkins/workspace/*************
  [Pipeline] {
  [Pipeline] stage
  [Pipeline] { (Declarative: Tool Install)
  [Pipeline] tool
  [Pipeline] envVarsForTool
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] withEnv
  [Pipeline] {
  [Pipeline] stage
  [Pipeline] { (Example)
  [Pipeline] tool
  [Pipeline] envVarsForTool
  [Pipeline] withEnv
  [Pipeline] {
  [Pipeline] sh
  + mvn --version
  /home/jenkins/workspace/*************@tmp/durable-d4209a18/script.sh: line 1: mvn: command not found
  [Pipeline] }
  [Pipeline] // withEnv
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] }
  [Pipeline] // withEnv
  [Pipeline] }
  [Pipeline] // node
  [Pipeline] End of Pipeline
  [BFA] Scanning build for known causes...
  [BFA] No failure causes found
  [BFA] Done. 0s
  ERROR: script returned exit code 127
  Finished: FAILURE
  </code></pre>
  
  <p>Why is the mvn command not found?</p>
  
  <p>I know there are apparently other ways to do this, but this is the example from the Jenkins documentation itself...</p>