通过在tools下来指定JDK

stage('Build') {tools { jdk "JDK8u231"}steps {sh '/var/jenkins_home/tools/apache-maven-3.6.3/bin/mvn package'}}

JDK8u231是在全局配置下配置过的JDK