You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2019/02/01 12:57:20 UTC
[sling-tooling-jenkins] branch master updated: SLING-8262 - Add
SonarQube analysis to Jenkins jobs
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-tooling-jenkins.git
The following commit(s) were added to refs/heads/master by this push:
new 3193e79 SLING-8262 - Add SonarQube analysis to Jenkins jobs
3193e79 is described below
commit 3193e792d64a8450ca1c01d92382933efcda9001
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Fri Feb 1 13:56:37 2019 +0100
SLING-8262 - Add SonarQube analysis to Jenkins jobs
Wrap the mvn execution in a withMvn block, otherwise mvn is not defined.
---
vars/slingOsgiBundleBuild.groovy | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/vars/slingOsgiBundleBuild.groovy b/vars/slingOsgiBundleBuild.groovy
index 481d147..1e667c5 100644
--- a/vars/slingOsgiBundleBuild.groovy
+++ b/vars/slingOsgiBundleBuild.groovy
@@ -25,10 +25,18 @@ def call(Map params = [:]) {
currentBuild.result = "SUCCESS"
}
+ // this might fail if there are no jdks defined, but that's always an error
+ // also, we don't activate any Maven publisher since we don't want this part of the
+ // build tracked, but using withMaven(...) allows us to easily reuse the same
+ // Maven and JDK versions
if ( env.BRANCH_NAME == "master" ) {
stage('SonarQube') {
withSonarQubeEnv('ASF Sonar Analysis') {
- sh 'mvn -U clean verify sonar:sonar ${additionalMavenParams}'
+ withMaven(maven: globalConfig.mvnVersion,
+ jdk: jenkinsJdkLabel(jobConfig.jdks[0], globalConfig),
+ publisherStrategy='EXPLICIT') {
+ sh 'mvn -U clean verify sonar:sonar ${additionalMavenParams}'
+ }
}
}
}
@@ -40,15 +48,20 @@ def call(Map params = [:]) {
}
}
+def jenkinsJdkLabel(int jdkVersion, def globalConfig) {
+ def label = globalConfig.availableJDKs[jdkVersion]
+ if ( !label )
+ throw new RuntimeException("Unknown JDK version ${jdkVersion}")
+ return label
+}
+
def defineStage(def globalConfig, def jobConfig, def jdkVersion, def isReferenceStage) {
def goal = jobConfig.mavenGoal ? jobConfig.mavenGoal : ( isReferenceStage ? "deploy" : "verify" )
def branchConfig = jobConfig?.branches?."$env.BRANCH_NAME" ?: [:]
def additionalMavenParams = branchConfig.additionalMavenParams ?
branchConfig.additionalMavenParams : jobConfig.additionalMavenParams
- def jenkinsJdkLabel = globalConfig.availableJDKs[jdkVersion]
- if ( !jenkinsJdkLabel )
- throw new RuntimeException("Unknown JDK version ${jdkVersion}")
+ def jenkinsJdkLabel = jenkinsJdkLabel(jdkVersion, globalConfig)
// do not deploy artifacts built from PRs or feature branches
if ( goal == "deploy" && env.BRANCH_NAME != "master" )