pipeline { agent any environment { scannerHome = tool 'SonarQube Scanner' } options { buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '10')) } tools { // Install the Maven version configured as "M3" and add it to the path. maven "/usr/share/maven" jdk "java-11" } stages { stage('Compile and Test') { steps { milestone 1 withSonarQubeEnv('SonarQube Production') { sh "mvn -Dmaven.test.failure.ignore=true clean test" } } } stage('Evaluate') { steps { milestone 1 withSonarQubeEnv('SonarQube Production') { sh "mvn-Dsonar.projectName=GitSearch -Dsonar.projectKey=GITSEARCH jacoco:report sonar:sonar" } } } } post { failure { notifyByEmail("Failure"); } unstable { notifyByEmail("Unstable"); } fixed { notifyByEmail("Fixed"); } } } void notifyByEmail(String reason) { def mailRecipients = "michael.breu@arctis.at" emailext ( subject: reason + ": Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'", body: '''${SCRIPT, template="groovy-html.template"}''', mimeType: 'text/html', recipientProviders: [[$class: 'CulpritsRecipientProvider']] ) }