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 3fa3696 SLING-8358 - Build should not fail if a project is not
onboarded to SonarCloud
3fa3696 is described below
commit 3fa3696e861579e9a790af8f8862e8ae929da3bb
Author: Robert Munteanu <[email protected]>
AuthorDate: Thu Apr 18 13:24:09 2019 +0300
SLING-8358 - Build should not fail if a project is not onboarded to
SonarCloud
Attempt to access the Maven error message with currentBuild.rawBuild.getLog
---
vars/slingOsgiBundleBuild.groovy | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/vars/slingOsgiBundleBuild.groovy b/vars/slingOsgiBundleBuild.groovy
index c103f43..2ac3bdd 100644
--- a/vars/slingOsgiBundleBuild.groovy
+++ b/vars/slingOsgiBundleBuild.groovy
@@ -48,11 +48,13 @@ def call(Map params = [:]) {
withMaven(maven: globalConfig.mvnVersion,
jdk: jenkinsJdkLabel(jobConfig.jdks[0],
globalConfig),
publisherStrategy: 'EXPLICIT') {
- def output = ""
try {
- output = sh (script: "mvn -U clean verify
sonar:sonar ${sonarcloudParams}", returnStdout: true).trim()
+ sh "mvn -U clean verify sonar:sonar
${sonarcloudParams}"
} catch ( Exception e ) {
- if ( output.contains("not authorized to
run analysis") ) {
+ def sonarCloudNotEnabled =
currentBuild.rawBuild.getLog(50).find {
+ line -> line.contains("not authorized
to run analysis")
+ }
+ if ( sonarCloudNotEnabled ) {
echo "Marking build unstable due to
missing SonarCloud onboarding. See
https://cwiki.apache.org/confluence/display/SLING/SonarCloud+analysis for steps
to fix."
currentBuild.result = 'UNSTABLE'
} else {