Setup SonarQube

Setup SonarQube

This article shows you how to set up SonarQube. SonarQube is a free open-source platform that facilitates measuring the overall code quality of the application (Static analysis). It can be used for detecting vulnerability like XSS and some bugs and could improvements in your code. It is a best practice if you can scan your code before going to the production.

Please follow the instructions are given below.

Firstly, you have to add SonarQube user to ubuntu computer.

sudo adduser --system --no-create-home --group --disabled-login sonarqube

Secondly, login to the Mysql server and create a user called SonarQube and database called “sonarqube”.

CREATE USER sonarqube@'localhost' IDENTIFIED BY '123456';

Then you have to grant privileges to sonarqube user.

GRANT ALL ON sonarqube.* to sonarqube@'localhost';

Next step is to download the SonarQube.

After that Unzip it and go to the SonarQube folder and goto conf folder and open and change the below lines.

sonar.jdbc.url=jdbc:mysql://localhost:3306/sonarqube?  useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false

Step – 7 go to the bin folder and choose your operating system

Step – 8 Open a terminal and start the

Finally, open the web browser and check
default username – admin
default password – admin

Once you Set up SonarQube in your computer you can upload your source code using maven command and you will be able to analyze your code. You can automate the scanning process using the Jenkins job with the GIT hub repository. As an example, you can create a Jenkins job to pull the source code from the GIT hub and upload it to the SonarQube server. In my next article, I will explain how to upload a Java project and how to measure the code coverage.

Please note – Now SonarQube does not support with MySQL

So Install postgress and new Steps are below,

sudo systemctl start postgresql
sudo systemctl enable postgresql
sudo passwd postgres
su - postgres
createuser sonarqube
ALTER USER sonarqube WITH ENCRYPTED password '123456';
CREATE DATABASE sonarqube OWNER sonarqube;

And do the changes as above in