Implement the SonarCloud stage
diff --git a/vars/slingOsgiBundleBuild.groovy b/vars/slingOsgiBundleBuild.groovy
index ae7849d..85d4706 100644
--- a/vars/slingOsgiBundleBuild.groovy
+++ b/vars/slingOsgiBundleBuild.groovy
@@ -63,7 +63,20 @@
if ( jobConfig.sonarCloud ) {
stage('SonarCloud') {
- echo "stub"
+ // As we don't have the global SonarCloud conf for now, we can't use #withSonarQubeEnv so we need to set the following props manually
+ def sonarcloudParams="-Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=apache"
+ // TODO below: replace SC_TOKEN by the right way to get Robert's SonarCloud token, probably using #withCredentials
+ sonarcloudParams="${sonarcloudParams} -Dsonar.login=${SC_TOKEN}"
+ // Params are different if it's a PR or if it's not
+ // Note: soon we won't have to handle that manually, see https://jira.sonarsource.com/browse/SONAR-11853
+ if ( isPrBuild ) {
+ sonarcloudParams="${sonarcloudParams} -Dsonar.pullrequest.branch=${CHANGE_BRANCH} -Dsonar.pullrequest.base=${CHANGE_TARGET} -Dsonar.pullrequest.key=${CHANGE_ID}"
+ } else {
+ sonarcloudParams="${sonarcloudParams} -Dsonar.branch.name=${BRANCH_NAME}"
+ }
+ // Alls params are set, let' execute
+ def mvnCmd = "mvn -U clean verify sonar:sonar ${sonarcloudParams}"
+ sh mvnCmd
}
}
// }
@@ -158,4 +171,4 @@
invocation.call()
}
}
-}
\ No newline at end of file
+}