github.com/drone/go-convert@v0.0.0-20240307072510-6bd371c65e61/convert/jenkins/testdata/Jenkinsfile.2 (about) 1 node { 2 stage('Checkout') { 3 checkout scm 4 } 5 6 stage('Build') { 7 mvn 'package' 8 } 9 } 10 11 def mvn(def args) { 12 def mvnHome = tool 'M3' 13 def javaHome = tool 'JDK8' 14 15 // Apache Maven related side notes: 16 // --batch-mode : recommended in CI to inform maven to not run in interactive mode (less logs) 17 // -V : strongly recommended in CI, will display the JDK and Maven versions in use. 18 // Very useful to be quickly sure the selected versions were the ones you think. 19 // -U : force maven to update snapshots each time (default : once an hour, makes no sense in CI). 20 // -Dsurefire.useFile=false : useful in CI. Displays test errors in the logs directly (instead of 21 // having to crawl the workspace files to see the cause). 22 23 // Advice: don't define M2_HOME in general. Maven will autodetect its root fine. 24 // See also 25 // https://github.com/jenkinsci/pipeline-examples/blob/master/pipeline-examples/maven-and-jdk-specific-version/mavenAndJdkSpecificVersion.groovy 26 withEnv(["JAVA_HOME=${javaHome}", "PATH+MAVEN=${mvnHome}/bin:${env.JAVA_HOME}/bin"]) { 27 sh "${mvnHome}/bin/mvn ${args} --batch-mode -V -U -e -Dsurefire.useFile=false" 28 } 29 }