github.com/drone/go-convert@v0.0.0-20240307072510-6bd371c65e61/convert/jenkins/testdata/Jenkinsfile.4 (about) 1 node { 2 catchError { 3 4 stage('Checkout') { 5 checkout scm 6 } 7 8 stage('Build') { 9 mvn 'clean install -DskipTests' 10 } 11 12 stage('Unit Test') { 13 mvn 'test' 14 } 15 16 stage('Integration Test') { 17 mvn 'verify -DskipUnitTests -Parq-wildfly-swarm ' 18 } 19 } 20 21 // Archive Unit and integration test results, if any 22 junit allowEmptyResults: true, 23 testResults: '**/target/surefire-reports/TEST-*.xml, **/target/failsafe-reports/*.xml' 24 25 statusChanged { 26 mail to: "${env.EMAIL_RECIPIENTS}", 27 subject: "${JOB_NAME} - Build #${BUILD_NUMBER} - ${currentBuild.currentResult}!", 28 body: "Check console output at ${BUILD_URL} to view the results." 29 } 30 } 31 32 def statusChanged(body) { 33 def previousBuild = currentBuild.previousBuild 34 if (previousBuild != null && previousBuild.result != currentBuild.currentResult) { 35 body() 36 } 37 } 38 39 def mvn(def args) { 40 def mvnHome = tool 'M3' 41 def javaHome = tool 'JDK8' 42 43 // Apache Maven related side notes: 44 // --batch-mode : recommended in CI to inform maven to not run in interactive mode (less logs) 45 // -V : strongly recommended in CI, will display the JDK and Maven versions in use. 46 // Very useful to be quickly sure the selected versions were the ones you think. 47 // -U : force maven to update snapshots each time (default : once an hour, makes no sense in CI). 48 // -Dsurefire.useFile=false : useful in CI. Displays test errors in the logs directly (instead of 49 // having to crawl the workspace files to see the cause). 50 51 // Advice: don't define M2_HOME in general. Maven will autodetect its root fine. 52 // See also 53 // https://github.com/jenkinsci/pipeline-examples/blob/master/pipeline-examples/maven-and-jdk-specific-version/mavenAndJdkSpecificVersion.groovy 54 withEnv(["JAVA_HOME=${javaHome}", "PATH+MAVEN=${mvnHome}/bin:${env.JAVA_HOME}/bin"]) { 55 sh "${mvnHome}/bin/mvn ${args} --batch-mode -V -U -e -Dsurefire.useFile=false" 56 } 57 }