SLING-8262 - Add SonarQube analysis to Jenkins jobs
Pass in sonar.pullrequest.github.repository
diff --git a/vars/slingOsgiBundleBuild.groovy b/vars/slingOsgiBundleBuild.groovy
index 16e1a5d..01c2bd3 100644
--- a/vars/slingOsgiBundleBuild.groovy
+++ b/vars/slingOsgiBundleBuild.groovy
@@ -32,8 +32,9 @@
// if ( env.BRANCH_NAME == "master" ) {
def additionalMavenParams = additionalMavenParams(jobConfig)
if ( env.BRANCH_NAME.startsWith("PR-") ) {
- sh 'printenv'
- additionalMavenParams="${additionalMavenParams} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.base=${CHANGE_TARGET} -Dsonar.pullrequest.provider=github -Dsonar.verbose=true"
+ def matches = env.CHANGE_URL =~ /https:\/\/github\.com\/([\w-]+)\/([\w-]+)\/pull\/\d+/
+ echo "Detected repo owner ${matches.group(1)} and repo name ${matches.group(2)}"
+ additionalMavenParams="${additionalMavenParams} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.base=${CHANGE_TARGET} -Dsonar.pullrequest.provider=github -Dsonar.verbose=true -Dsonar.pullrequest.github.repository=${matches.group(1)}/${matches.group(2)}"
}
stage('SonarQube') {
withSonarQubeEnv('ASF Sonar Analysis') {