Setting Up Sonar on Local - Yash-777/sonar-java GitHub Wiki

Instance components

A SonarQube instance comprises three components:

Setting Up Sonar on Local

Sonar Server Setup

  1. Download the Sonar Server from http://www.sonarqube.org/downloads/
  2. Download and Install MySQL Server and MySQL Workbench.
  3. Go to MySQL Workbench and create a new Schema and name it ‘sonar’.
  4. Update the sonar.properties @location to <sonar server location>\conf.
    1. Comment the embedded database and uncomment the following line to use MySQL.
    2. sonar.jdbc.url: jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
  5. Comment out jdbc.url: jdbc:h2:tcp://localhost:9092/sonar.
  6. Set sonar.jdbc.username with value ‘root’ and sonar.jdbc.password as empty.
  7. Go to \bin and locate the folder as per your operating system.
  8. Run StartSonar.bat from the folder.
  9. Verify that your Server is up and running. http://localhost:9000(Default Port)

Sonar Runner Setup

  1. Download the Sonar Runner from http://www.sonarqube.org/downloads/
  2. Update the sonar.runner.properties @location to <sonar runner location>\conf.sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true

Add Project to SONAR

  1. Create a sonar-project.properties file with the following properties
    1. sonar.projectKey=’YourProjectKey'(without quotes)
    2. sonar.projectName=’YourProjectName'(without quotes)
    3. sonar.projectVersion=5.0
    4. sonar.projectDescription=’Project Description'(without quotes)
    5. sonar.sources=(Path to the source code folder of your project)
    6. sonar.language=java
    7. sonar.sourceEncoding=UTF-8
  2. Save the above created properties file to your project folder.
  3. Add the following path in environment variables
  4. /bin
  5. Open CMD, navigate to your project folder where the above created properties file is placed and run sonar-runner command. This will run reports and upon successful execution, the sonar report can be viewed on the browser (http://localhost:9000)