How can I Run A Sonar Analysis Without Maven?


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.

  2. Configure the Sonarqube server

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

  3. Configure the Sonarqube Scanner

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

  4. Configure the job

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

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


Have more questions?


  • 0
    Kishore Bhatia

    Use-case: when running this Sonar Analysis build on a distributed build-node (and not the master itself) - If you see an error related to JDBC source or db connection failure, then provide additional args for jdbc source and make sure the build-node is able to connect with that jdbc source (IP/port).
    try with this additional arg (sample values shown)-
    -Dsonar.jdbc.url=jdbc:h2:tcp://sonar-vm:9092/sonar (replace with actual jdbc url)

    The sonar-runner output should reflect jdbc src arg like: C:\sonar-runner-2.4\bin\sonar-runner.bat -e -Dsonar.jdbc.url=jdbc:h2:tcp://host:port/sonar ...

  • 0
    Rekha Karavate


    I want to run sonarqube analysis for the C code using Jenkinsfile. How can I use SoanrQube for the C project?I guess I need to use Build Wrapper. But I didn't get much information how to use build Wrapper in jenkins. Thanks.

  • 0
    Denys Digtiar

    Hi Rekha,

    I believe you can find an answer to your question in the documentation, here is a link:

    Analyzing in a Jenkins Pipeline

Please sign in to leave a comment.