mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-10-26 08:06:09 +01:00
Jenkins: Updates SonarQube analysis props for SonarCloud and BitBucket.
This commit is contained in:
44
Jenkinsfile
vendored
44
Jenkinsfile
vendored
@@ -1,5 +1,5 @@
|
||||
#!groovy
|
||||
@Library('github.com/cloudogu/ces-build-lib@ac17d45')
|
||||
@Library('github.com/cloudogu/ces-build-lib@9aadeeb')
|
||||
import com.cloudogu.ces.cesbuildlib.*
|
||||
|
||||
node() { // No specific label
|
||||
@@ -19,13 +19,16 @@ node() { // No specific label
|
||||
// Maven build specified it must be 1.8.0-101 or newer
|
||||
def javaHome = tool 'JDK-1.8.0-101+'
|
||||
|
||||
withEnv(["JAVA_HOME=${javaHome}", "PATH=${env.JAVA_HOME}/bin:${env.PATH}"]) {
|
||||
withEnv(["JAVA_HOME=${javaHome}", "PATH=${env.JAVA_HOME}/bin:${env.PATH}",
|
||||
// Give Maven enough memory to do SonarQube analysis
|
||||
"MAVEN_OPTS=-Xmx1g"]) {
|
||||
|
||||
stage('Checkout') {
|
||||
checkout scm
|
||||
}
|
||||
|
||||
stage('Build') {
|
||||
// TODO release build only on default? or 2.0.0-M3 -> JavaDoc takes ages
|
||||
mvn 'clean install -DskipTests -DperformRelease -Dmaven.javadoc.failOnError=false'
|
||||
}
|
||||
|
||||
@@ -34,9 +37,15 @@ node() { // No specific label
|
||||
}
|
||||
|
||||
stage('SonarQube') {
|
||||
def sonarQube = new SonarQube(this, 'ces-sonar')
|
||||
|
||||
sonarQube.analyzeWith(mvn)
|
||||
def sonarQube = new SonarQube(this, 'sonarcloud.io')
|
||||
|
||||
// TODO move this to ces-build-lib so we can use "sonarqube.analyzeWith(mvn)" here
|
||||
analyzeWith(mvn)
|
||||
|
||||
if (!sonarQube.waitForQualityGateWebhookToBeCalled()) {
|
||||
currentBuild.result = 'UNSTABLE'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,3 +58,30 @@ node() { // No specific label
|
||||
|
||||
mailIfStatusChanged(defaultEmailRecipients)
|
||||
}
|
||||
|
||||
void analyzeWith(Maven mvn) {
|
||||
|
||||
withSonarQubeEnv('sonarcloud.io') {
|
||||
|
||||
String mvnArgs = "${env.SONAR_MAVEN_GOAL} " +
|
||||
"-Dsonar.host.url=${env.SONAR_HOST_URL} " +
|
||||
"-Dsonar.login=${env.SONAR_AUTH_TOKEN} "
|
||||
|
||||
if (isPullRequest()) {
|
||||
echo "Analysing SQ in PR mode"
|
||||
mvnArgs += "-Dsonar.pullrequest.base=${env.CHANGE_TARGET} " +
|
||||
"-Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} " +
|
||||
"-Dsonar.pullrequest.key=${env.CHANGE_ID} " +
|
||||
"-Dsonar.pullrequest.provider=bitbucketcloud " +
|
||||
"-Dsonar.pullrequest.bitbucketcloud.owner=sdorra " +
|
||||
"-Dsonar.pullrequest.bitbucketcloud.repository=sonarcloudtest "
|
||||
} else {
|
||||
mvnArgs += " -Dsonar.branch.name=${env.BRANCH_NAME} "
|
||||
if (!"default".equals(env.BRANCH_NAME)) {
|
||||
// Avoid exception "The main branch must not have a target" on master branch
|
||||
mvnArgs += " -Dsonar.branch.target=default "
|
||||
}
|
||||
}
|
||||
mvn "${mvnArgs}"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user