tumblr counter

SonarQube Tutorial

Also append C:\sonar\sonar-runner-2.3\bin to Path.

Set Sonar Path Variable

Note

 

CREATE USER 'sonar' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
FLUSH PRIVILEGES;
		
  1. In this tutorial, we are using h2 database which is default configured with SonarQube, You can also use any of these databases (mysql,plsql,oracle etc),
    For example, If you are using mysql, just execute the following sql script
  2. Edit sonar.properties in  \conf\sonar.properties.

    just comment Connection url for h2 and uncomment Connection url for mysql

    sonar.jdbc.url:jdbc:h2:tcp://localhost:9092/sonar
    sonar.jdbc.url: jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true

 

# Required metadata
sonar.projectKey=java-sonar-runner-simple
sonar.projectName=Simple Java project analyzed with the SonarQube Runner
sonar.projectVersion=1.0

# Comma-separated paths to directories with sources (required)
sonar.sources=src

# Language
sonar.language=java

# Encoding of the source files
sonar.sourceEncoding=UTF-8

Sonar Project Structure

  1. Set a new environment variable as SONAR_RUNNER_HOME. And its value should be C:\sonar\sonar-runner-2.3 (unzipped path of sonar-runner.zip)
    1. From the Desktop, right click on My Computer and click Properties.
    2. Click Advanced System Settings link in the left column.
    3. In the System Properties window click the Environment Variables button.
    4. Inside System variable, click on New Button
  2. Create a new Java Project and add below sonar-project.properties file into the root of the project folder (see below project strcuture)

  3. sonar-project.properties
  4. Using the terminal go the project home and run the command sonar-runner (Sonar Server must be started)
  5. After the success run browse the web  http://localhost:9000 where you can see the report related to the project

    Sonar Project Report

Previous 1 2





5 Responses to “SonarQube Tutorial”
  1. Nicole 13.11.2013 06:35:34
  1. admin 14.11.2013 02:00:18
  1. sravan 04.03.2014 06:34:01
  1. Priti 30.09.2014 18:05:09
  1. admin 15.10.2014 09:17:04

Your email address will not be published. Required fields are marked *