5

Using Jenkins 1.642.2 for code analysis with SonarQube 5.6.1 for all my maven projects.

When I use maven goal sonar:sonar they take more time to analyse files (more than 7 seconds by file) :

[INFO] Sensor SCM Sensor
[INFO] SCM provider for this project is: svn
[INFO] 1079 files to be analyzed
[INFO] 
[INFO] 2/1079 files analyzed
[INFO] 3/1079 files analyzed
[INFO] 4/1079 files analyzed
[INFO] 5/1079 files analyzed

When I use the SonarQube Scanner with this config :

SonarQube Server

SonarQube scanner

SonarQube scanner

then i have this error :

WARN: Property 'sonar.jdbc.url' is not supported any more. It will be  ignored. There is no longer any DB connection to the SQ database.
WARN: Property 'sonar.jdbc.username' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
WARN: Property 'sonar.jdbc.password' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
INFO: User cache: /var/lib/jenkins/.sonar/cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=43ms
INFO: SonarQube server 5.6.1
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is  platform dependent)
INFO: Process project properties
INFO: ---------------------------------------------------------------------- --
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 1.621s
INFO: Final Memory: 39M/132M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: You must define the following mandatory properties for 'Unknown':   sonar.projectKey, sonar.projectName, sonar.projectVersion, sonar.sources
ERROR: 
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug    logging.
Build step 'Execute SonarQube Scanner' marked build as failure
Finished: FAILURE

My settings file :

<profile>
        <id>sonar</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <sonar.jdbc.url>
            jdbc:mysql://11.230.5.88:3306/sonar
            </sonar.jdbc.url>
            <sonar.jdbc.username>sonar</sonar.jdbc.username>
            <sonar.jdbc.password>sonar</sonar.jdbc.password>
            <!-- Optional URL to server. Default value is http://localhost:9000 -->
            <sonar.host.url>
              http://sonarqube-groupe.com/
            </sonar.host.url>
        </properties>
    </profile>

Any idea to solve this problem because i have a problem to understand the new sonarqube use

i must make a sonar-project.properties file for the maven project?

Inforedaster
  • 1,260
  • 1
  • 23
  • 39

1 Answers1

10

You can and should still analyze with Maven, using a Build Step. As stated in the docs, you should first "Enable injection of SonarQube server configuration" at the global configuration level, and then in your build enable the Build Environment Option "Prepare SonarQube Scanner environment". Then you can set your Maven goal to the following:

$SONAR_MAVEN_GOAL -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_AUTH_TOKEN
G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
  • It's ok now but i still have the problem of slowness during analysis !! is related to the new version of sonarqube? [INFO] SCM provider for this project is: svn [INFO] 1079 files to be analyzed [INFO] [INFO] 2/1079 files analyzed [INFO] 3/1079 files analyzed [INFO] 4/1079 files analyzed [INFO] 5/1079 files analyzed [INFO] 6/1079 files analyzed [INFO] 7/1079 files analyzed [INFO] 8/1079 files analyzed [INFO] 9/1079 files analyzed [INFO] 10/1079 files analyzed [INFO] 11/1079 files analyzed [INFO] 13/1079 files analyzed any idea ? – Inforedaster Sep 28 '16 at 15:08
  • It took me quite a while to realize why my jobs do not have such a "Prepare SonarQube Scanner environment". It is only displayed if the flag "Enable injection of SonarQube server configuration as build environment variables" is set in the global Jenkins configuration! – dokaspar Aug 10 '17 at 09:46
  • Thanks @dokaspar. I've expanded the answer to include that. – G. Ann - SonarSource Team Aug 10 '17 at 11:28