The following two tabs change content below.
Hi, I have written and developed this site to share my experience and ideas with other colleagues. I also started to prepare interview questions and answers for job seekers. I hope it will help you a lot.

What is Sonar/SonarQube?

SonarQube™ software (previously known as “Sonar”). Sonar is an open source Platform used by development teams to manage source code quality.

As such, Sonar provides code analyzers, reporting tools, defects hunting modules and TimeMachine as core functionality. But it also embarks a plugin mechanism enabling the community to extend the functionality (more than 35 plugins available), making Sonar the one-stop-shop for source code quality by addressing not only developers but also managers needs.

It is entirely written in java and supported for other 25+ languages such as Java, C/C++, C#, PHP, Flex, Groovy, JavaScript, Python, PL/SQL, COBOL, etc, it is also used for Android Development.

Sonar Software Installation:

1. Download the latest sonar from SonarQube Website
Note : if you are going to download SonarQube latest version which is greater then or equal to 5.6.1 then you should use JDK 8 or any upper version of java.

2. Unzip the downloaded file in any specific drive.

3. Set the path of sonar in environment variable till D:\sonar\sonarqube-5.6.1\sonarqube-5.6.1 like below:

sonar_path

4.  After setting the path variable you can start the Sonar web server using “StartSonar” command like below:

sonar_server

5. If StartSonar command runs successfully then means all are good. Sonar server runs on 9000 port and its is ready to use now.

6. You can open Sonar dashboard in browser : http://localhost:9000/  and below is screenshot of dashboard

sonar_dashboard

 

Now configuring the Sonar Runner Analysing tool.

1. Download the sonar runner from this maven repo .

2. Extract/Unzip sonar runner into a specific drive and set the SONAR_RUNNER_HOME environment variable like:

sonnar_runner_home

and set “SONAR_RUNNER_HOME” to path variable and append /bin like :

sonnar_runner_path

After all these variable pls open the command prompt and run sonar-runner command. Just to check if we set the sonar runner successfully or not. after this command output will be like this.

sonar_runner_command

 

Creating Project & Analysing Using Sonar

1. Create a new project or you can use your ongoing project also.

2. Under the root directory of project create a file with name “sonar-project.properties”

3. For setup purpose, just change the value of sonar.projectName to the project name you created in sonar-project.properties file like.

java_project

4. Now go to root directory of project and run “sonar-runner” command.

sonar_runner_command_1

Now this command should run success without any issue.

5. All are set now you can view the Analysing report on sonar web server dashboard like:

sonar_project_setup

 

In next post will share how to set the rules on sonar web server.

476 total views, 1 views today

One thought on “Sonar installation and configuration”

Leave a Reply

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