SonarQube configuration tutorial

This post will be a simple tutorial to install, configure and use SonarQube to analyse your project code quality. This tutorial will be directed to C# and JavaScript projects in a Windows environment.

1- Download SonarQube

2- Create a SQL Server database

If you don't have SQL Server installed download SQL Server Express, a free and limited SQL Server edition option (SQL Server editions comparison here).

Run the following command:


Just after this command the collation from the recently created database needs to be changed as recommended in the SonarQube website:


If you want to see the current database collation run:

SELECT CONVERT (varchar, SERVERPROPERTY('collation'));

3- Change the <sonar_directory>/conf/ file

In the file you configure a lot of stuff regarding hosting and persisting data from SonarQube. We just going to configure which database SonarQube will connect and in which port will be hosted. To do that just add the two following lines:

In order to SonarQube successfully connect in the SQL Server database you are going to need to enable the TCP/IP protocol in the database instance you are intending to use. Also make sure that the TCP port being used is the SQL Server default port 1433.

One more detail, if you are using SQL Authentication instead of Windows Authentication you are going to need to add the two following parameters:

4- Start SonarQube

Go to the <sonar_directory>/bin/windows-x86-64 folder (or whatever Windows you are using) and run the StartSonar.bat file. If everything goes well you are going to see the SonarQube dashboard.

5- Install the C# and JavaScript plugins

In SonarQube login with the default admin/admin user and then follow the steps:

6- Create a new SonarQube project

Just follow the steps:

7- Download the SonarQube Scanner

8- Go to the <sonar_scanner_directory>/conf/ and add the two following lines:

9- Add a new environment variable called SONAR_RUNNER_HOME pointing to

the <sonar_scanner_directory>

10- Add <sonar_scanner_directory>/bin to the PATH

11- Add a new file called in your Visual Studio solution root folder with the following contents:

12- Move the entire <sonar_scanner_directory> to your solution root folder

13- Run the command sonar-runner in your solution root folder

After a successful SonarQube analysis you are going to see something similar to this:

SonarQube successful analysis

Just go to the indicated link (http://localhost:9000/dashboard/index/YourProject) and then see the SonarQube analysis report.

SonarQube analysis report


comments powered by Disqus