How can I Run A Sonar Analysis Without Maven?

Article ID:204947684
2 minute readKnowledge base


Some project don’t build using maven but require a sonar analysis to execute against the code in the workspace.



Sonar runner is usually executed as a maven plugin but Jenkins can invoke it without the need of maven through the Execute SonarQube Scanner task.

  1. Ensure that the SonarQube plugin for Jenkins is installed through the plugin manager

    Navigate to Manage Jenkins -> Manage Plugins` and ensure that the latest version of SonarQube plugin is installed. plugin_install.png

  2. Configure the Sonarqube server

    Navigate to Manage Jenkins > Configure System > SonarQube servers and configure your sonar installation sonarqube_server.png

  3. Configure the Sonarqube Scanner

    Navigate to Manage Jenkins > Global Tool Configuration > SonarQube Scanner and add a new Sonarqube Scanner Installation sonarqube_scanner.png

  4. Configure the job

    Navigate to the job configuration and add an Execute SonarQube Scanner build step with the proper configuration. sonarqube_job_config.png

Once configured, you should expect to see output similar to this example indicating that sonar runner is working:

[test] $ /Users/dvilladiego/.jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_Scanner_2.8/bin/sonar-scanner scan -e -Dsonar.language=java "-Dsonar.projectName=Test Java project analyzed with the SonarQube Runner" -Dsonar.projectVersion=1.0 -Dsonar.sourceEncoding=UTF-8 -Dsonar.projectKey=test-project -Dsonar.sources=src -Dsonar.projectBaseDir=/Users/dvilladiego/.jenkins/workspace/test
INFO: Option -e/--errors is no longer supported and will be ignored
INFO: Scanner configuration file: /Users/dvilladiego/.jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube_Scanner_2.8/conf/
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 2.8
INFO: Java 1.8.0_74 Oracle Corporation (64-bit)
INFO: Mac OS X 10.11.3 x86_64
INFO: User cache: /Users/dvilladiego/.sonar/cache
INFO: Load global repositories
INFO: Load global repositories (done) | time=128ms
INFO: User cache: /Users/dvilladiego/.sonar/cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=6ms
INFO: SonarQube server 6.2
INFO: Default locale: "es_ES", source code encoding: "UTF-8"
INFO: Process project properties
INFO: Load project repositories
INFO: Load project repositories (done) | time=15ms
INFO: Load quality profiles