Search code examples
javajenkinssonarqube

Build on jenkins failed couse sonarqube analysis failed


In sonarqube log I have : Caused by: java.lang.IllegalStateException: Fail to process issues of component 'com.mts:mts:src/main/java/com/mts/web/dao/masterdata/StandardRate.java:BRANCH:develop' Caused by: java.lang.IllegalStateException: The property 'sonar.alm.github.app.id' is not an long value: For input string: "sonarapp

Pipeline for sonarqube configuration is:

           steps {
               withSonarQubeEnv('Central Sonar') {
                   withCredentials([string(credentialsId: 'crdb_github_token', variable: 'TOKEN'), string(credentialsId: 'mts_sonarcube_token', variable: 'SONAR_TOKEN')]) {
                       script {
                           def goals = 'sonar:sonar  '
                           def opts = "-Dsonar.host.url=${SONAR_HOST_URL} " +
                                   "-Dsonar.login=${SONAR_TOKEN} "

                           try {
                               if (env.CHANGE_ID != null && env.CHANGE_ID != '') {
                                   opts += "-Dsonar.analysis.mode=preview " +
                                           "-Dsonar.github.pullRequest=${env.CHANGE_ID} " +
                                           "-Dsonar.github.oauth=${TOKEN} " +
                                           "-Dsonar.github.repository=IPT-CRDB-2213/mts " +
                                           "-Dsonar.github.endpoint=https://git.com/api/v3"

                                   // sh "${scannerHome}/bin/sonar-scanner ${opts}"
                                   def oldOpts = rtMaven.opts
                                   rtMaven.opts = opts
                                   rtMaven.run pom: 'pom.xml', goals: goals
                                   rtMaven.opts = oldOpts
                               } else if (env.UNIFIED_BRANCH_NAME == 'master' || env.UNIFIED_BRANCH_NAME == 'develop')  {
                                   opts += "-Dsonar.branch.name=${env.UNIFIED_BRANCH_NAME}"

                                   // sh "${scannerHome}/bin/sonar-scanner ${opts}"
                                   def oldOpts = rtMaven.opts
                                   rtMaven.opts = opts
                                   rtMaven.run pom: 'pom.xml', goals: goals
                                   rtMaven.opts = oldOpts
                               }
                           } catch (err) {
                               echo err.getMessage()
                               echo "Error detected, but we will continue."
                           }
                       }
                   }
               }
           }
       } ``` 

Solution

  • Finally helped to run sonarcube analysis from local: mvn sonar:sonar -Dsonar.host.url= -Dsonar.login=