From 2c732c91c8476ad0b571aaea05df4443dbe032f6 Mon Sep 17 00:00:00 2001 From: Lukasz Lenart Date: Sat, 8 Feb 2020 18:11:41 +0100 Subject: [PATCH] Uses SonarCloud settings --- Jenkinsfile | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ee4f81da7..8d67d898a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,6 +11,7 @@ pipeline { buildDiscarder logRotator(daysToKeepStr: '14', numToKeepStr: '10') timeout(80) disableConcurrentBuilds() + skipStagesAfterUnstable() } triggers { pollSCM 'H/15 * * * *' @@ -28,7 +29,8 @@ pipeline { } post { always { - junit '**/target/surefire-reports/*.xml' + junit(testResults: '**/surefire-reports/*.xml', allowEmptyResults: true) + junit(testResults: '**/failsafe-reports/*.xml', allowEmptyResults: true) } } } @@ -37,8 +39,8 @@ pipeline { branch 'master' } steps { - withSonarQubeEnv('ASF Sonar Analysis') { - sh 'mvn -P${JENKINS_PROFILE} sonar:sonar' + withCredentials([string(credentialsId: 'asf-struts-sonarcloud', variable: 'SONARCLOUD_TOKEN')]) { + sh 'mvn sonar:sonar -DskipAssembly -Dsonar.projectKey=apache_struts -Dsonar.organization=apache -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${SONARCLOUD_TOKEN}' } } } @@ -76,4 +78,53 @@ pipeline { } } } + post { + // If this build failed, send an email to the list. + failure { + script { + emailext( + subject: "[BUILD-FAILURE]: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]'", + body: """ + BUILD-FAILURE: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]': + + Check console output at "${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]" + """.stripMargin(), + to: "dev@struts.apache.org", + recipientProviders: [[$class: 'DevelopersRecipientProvider']] + ) + } + } + + // If this build didn't fail, but there were failing tests, send an email to the list. + unstable { + script { + emailext( + subject: "[BUILD-UNSTABLE]: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]'", + body: """ + BUILD-UNSTABLE: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]': + + Check console output at "${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]" + """.stripMargin(), + to: "dev@struts.apache.org", + recipientProviders: [[$class: 'DevelopersRecipientProvider']] + ) + } + } + + // Send an email, if the last build was not successful and this one is. + fixed { + script { + emailext( + subject: "[BUILD-STABLE]: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]'", + body: """ + BUILD-STABLE: Job '${env.JOB_NAME} [${env.BRANCH_NAME}] [${env.BUILD_NUMBER}]': + + Is back to normal. + """.stripMargin(), + to: "dev@struts.apache.org", + recipientProviders: [[$class: 'DevelopersRecipientProvider']] + ) + } + } + } }