Install Sonarqube in Windows

Posted by & filed under MYSQL, Sonarqube.

What is SonarQube:

SonarQube is an open source code quality management platform that allows developer teams to manage, track and eventually improve the quality of the source code. It’s a web based application that keeps historical data of a variety of metrics. It comes with more than 20 plugins to support multiple languages like Java, C#, C/C++, PL/SQL, Cobol, PHP, HMTL, CSS, JavaScript and etc. The SonarQube is not only analysis code, also detects coding rules violations.

Installl SonarQube To Analyse PHP script  Using MySQL In windows

Download SonarQube and SonarRunner from SonarQube Site:

Please download both SonarQube and SonarRunner using following link, and extract both SonarQube and SonarRunner in to C: directive like this ( “C:sonarqube” and “C:sonar-runner” ).

http://www.sonarqube.org/downloads/

Install MySQL Database For SonarQube:

SonarQube will save all analysed data in database. By default SonarQube using H2 database, but it is not recommanded to use for performance wise. So we are going to use MySQL database to save analysed data.

I have already installed MySQL database in my local system using XAMPP package. If you are not installed, then download MySQL and install it in your local system. Once you successfully installed MySQL database then start it.

Create MySQL database and database user, and grant full permission to the user using the following SQL query.


CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
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;

Do MySQL Configuration Change For SonarQube Installation:

Now set the innodb_buffer_pool_size in my.ini configuration file. In my case my.ini file exists in the following directory C:xamppmysqlbin. Set innodb_buffer_pool_size minimum of 1024m, and maximum of 4096M.


innodb_buffer_pool_size = 1024M

OR


innodb_buffer_pool_size = 4096M

Now select created database with root access to set query_cache_size parameter. So before running below query change your working directory to mysql bin folder.

cd C:xamppmysqlbin


mysql -u root -p sonar

now it will ask you to enter password, most probably root user won’t have password. So just press enter to continue.
Now run the below SQL queries one by one to set and check query_cache_size.


mysql> SET GLOBAL query_cache_size =67108864;
mysql> SHOW VARIABLES LIKE 'query_cache_size';

First command will set query_cache_size, then second command we run to check the query_cache_size setted successfully.

Set query_cache_size MySQL SonarQube Installation

 

 

Assign MySQL Database Credentials in Sonarqube sonar.properties file:

Now assign your MySQL database credentials in the Sonarqube sonar.properties file i.e. in the C:sonarqubeconf folder. Change the following credentials.


sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance

If anything commented, then please remove # symbol before above lines and assign your correct credentials.

Also uncomment following lines which set the HeapMemory


sonar.web.javaOpts=-Xmx768m -Xms256m -XX:MaxPermSize=160m -XX:+HeapDumpOnOutOfMemoryError -Djava.net.preferIPv4Stack=true

Finally set the host and port.


sonar.web.host=127.0.0.1
sonar.web.port=9000

Now you have successfully done all the configuration related things. Now go to Sonarqube bin folder, then select windows 32 or 64 bit folder based your OS & JDK, and run StartSonar.bat file to start Sonarqube server. Mine is 64 bit OS and also installed 64 bit JDK, So I will select C:sonarqubebinwindows-x86-64 folder.

I will start Sonarqube server via command line tool, to know if any error occurs during start of the server. So please change your working directory like using following command.

cd C:sonarqubebinwindows-x86-64

then type to start the server.

StartSonar.bat

If server successfully starts then it will shows Process[web] is up.

Start SonarQube Server

 

now access the your Sonarqube server using the following URL in browser.

http://localhost:9000/

If everything ok then it must show page like in the below image.
Sonnarqube Dashboard Page

SonarQube Proxy Server Settings:

If you are behind proxy server, then all the request you are going to make will go via proxy server only. If you are not set proxy related settings in “sonar.properties”, then you will not able to install any plugins from SonarQube server.

Please add the following line in your “sonar.properties” file and assign your proxy server host URL, port, username and password.


sonar.web.javaAdditionalOpts=-Dhttp.proxyHost=proxy.com -Dhttp.proxyPort=8080 -Dhttp.proxyUser=username -Dhttp.proxyPassword=password

Download Premium Only Scripts & 80+ Demo scripts Instantly at just 1.95 USD per month + 10% discount to all Exclusive Scripts

If you want any of my script need to be customized according to your business requirement,

Please feel free to contact me [at] muni2explore[at]gmail.com

Note: But it will be charged based on your customization requirement

Get Updates, Scripts & Other Useful Resources to your Email

Join 10,000+ Happy Subscribers on feedburner. Click to Subscribe (We don't send spam)
Every Email Subsciber could have access to download 100+ demo scripts & all future scripts.

Get Instant Script Download Access!