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 e93539e  SLING-8358 - Build should not fail if a project is not 
onboarded to SonarCloud
e93539e is described below

commit e93539e05508af9dd831355ca7fede96cb812d11
Author: Robert Munteanu <[email protected]>
AuthorDate: Thu Apr 18 13:11:44 2019 +0300

    SLING-8358 - Build should not fail if a project is not onboarded to 
SonarCloud
    
    Better attempt to detect missing SonarCloud onboarding.
---
 vars/slingOsgiBundleBuild.groovy | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/vars/slingOsgiBundleBuild.groovy b/vars/slingOsgiBundleBuild.groovy
index 1566b82..7cbcc23 100644
--- a/vars/slingOsgiBundleBuild.groovy
+++ b/vars/slingOsgiBundleBuild.groovy
@@ -48,12 +48,16 @@ def call(Map params = [:]) {
                         withMaven(maven: globalConfig.mvnVersion, 
                             jdk: jenkinsJdkLabel(jobConfig.jdks[0], 
globalConfig),
                             publisherStrategy: 'EXPLICIT') {
+                                def output = ""
                                 try {
-                                    sh "mvn -U clean verify sonar:sonar 
${sonarcloudParams}"
+                                    output = sh (script; "mvn -U clean verify 
sonar:sonar ${sonarcloudParams}", returnStdout: true).trim()
                                 } catch ( Exception e ) {
-                                    // TODO - find a better solution? 
https://stackoverflow.com/questions/55742773/get-the-cause-of-a-maven-build-failure-inside-a-jenkins-pipeline
-                                    echo "Marking build unstable, potentially 
due to missing SonarCloud onboarding. See 
https://cwiki.apache.org/confluence/display/SLING/SonarCloud+analysis for steps 
to fix."
-                                    currentBuild.result = 'UNSTABLE'
+                                    if ( output.contains("not authorized to 
run analysis") ) {
+                                        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 {
+                                        throw e;
+                                    }
                                 }
                         }
                     }

Reply via email to