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