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