Blog Detail

preview image DevOps
by Anurag Srivastava, Jun 2, 2018, 10:49:54 AM | 4 minutes

Analyze your project with SonarQube

In my previous two blogs I have explained the benefit of SonarQube and how to install it on Ubuntu machine but this information is incomplete unless you know how to use it. If you want to know the Jenkins and SonarQube installation process and configuration then refer to my previous blog:

Why SonarQube is important for IT projects ?  
Configure Jenkins for Automated Code Deployment 
SonarQube installation on Ubuntu 
Configure SonarQube Scanner with Jenkins 
Install Jenkins on Ubuntu  

In this blog I am going to explain the complete process to setup a project and scan it using SonarQube. Let say I have a project for blog and it is located at:


We have installed SonarQube server but to scan a project we also need the sonar-scanner so now we need  to install sonar-scanner.

Install sonar-scanner on ubuntu:
To install sonar-scanner we have to follow these steps:
1) Download the sonar-scanner file.
2) Expand the downloaded file into /opt/sonar/ directory.
3) Open the file:

vim /opt/sonar/sonar-scanner-

4) Set the SonarQube server location:

#----- Default SonarQube server

5) Now Add the /opt/sonar/sonar-scanner- directory to your path. We can also use export command to setup the path:

export PATH=$PATH:/opt/sonar/sonar-scanner-

Project setup for SonarQube:

Now I need to setup SonarQube to check the code quality of blog project so that I can fix the possible code issues. So for SonarQube setup with blog project, I am going to explain the setup in a step by step way so that you can easily understand the process:

1) Open the SonarQube application on a browser and login. For opening the software we need to type the following URL:


If you have not installed SonarQube on your local machine then type the URL of the SonarQube server.

2) Click on 'Administration' link on the top menu to open the administration page.

3) Click on 'Projects' link under administration and from drop down click on 'Management' link. This will open the projects management page. On this page we can see the project listing.

4) Click on 'Create Project' button on top-right part of the page.

5) This will open the popup for project creation where we need to enter the project name and key etc.

6) Go to to your project directory using following command on terminal:

cd /var/www/html/blog/

7) Now create a file as ''

sudo vim

8) In the file add following code:

# must be unique in a given SonarQube instance
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
# This property is optional if sonar.modules is set.

9) Now run the following command to scan the project:


10) On successful execution we will get the success message.

11) Sometimes because of framework files the report size increase and creates issues during upload. This causes the error in scanner execution. For fixing this issue we can add following line in our project's file:

sonar.exclusions=directory1/**, directory2/**, public/**

12) After successful execution of sonar-scanner we can go to the browser to check the SonarQube server.

13) Click on 'Projects' link from top menu, this will list the project listing page.

14) Now click on 'blog'  project which we have created for this demo.

This way we can setup a project on SonarQube and can scan the project directory to get the complete insight. I will explain the report analysis part in my next blog. Hope this series will help you to understand the SonarQube configuration for any project.

In case of any query or doubt please leave a comment.

About Author

Anurag Srivastava

Author | Blogger | Tech Lead | Elastic Stack | Innovator |

View Profile

Comments (3)

  • user image
    Ravi Geetha Vandana
    Mar 27, 2019, 12:32:53 PM

    while downloading the sonar scanner using the link you provided it is not working

  • user image
    Ravi Geetha Vandana
    Mar 28, 2019, 12:42:49 PM

    while creating it is showing [ Error writing Permission denied ]

  • user image
    Ravi Geetha Vandana
    Mar 30, 2019, 1:16:34 PM

    How To Generate PDF Report Of Code Analysis In SonarQube for sonar7.6 version

Leave a comment

Related Blogs

Configuring Django application with Elastic APM

Jan 14, 2020, 10:22:34 AM | Anurag Srivastava

Monitoring Application using Elastic APM

Jan 16, 2020, 11:43:29 AM | Anurag Srivastava

MySQL Performance Tuning

Jan 31, 2018, 6:15:34 AM | Anurag Srivastava

Introduction to Logstash

Dec 20, 2019, 11:38:31 AM | Anurag Srivastava

Introduction to Elastic APM

Jan 7, 2020, 7:15:34 PM | Anurag Srivastava

Configure Logstash to send MongoDB data into Elasticsearch

Mar 9, 2019, 8:20:38 AM | Anurag Srivastava

Why monitoring is important?

Jan 6, 2020, 7:30:13 PM | Anurag Srivastava

Snapshot and Restore Elasticsearch Indices

Sep 16, 2019, 5:55:06 AM | Anurag Srivastava

Configure Logstash to push MySQL data into Elasticsearch

Feb 9, 2019, 12:06:18 PM | Anurag Srivastava

Log analysis with Elastic stack

Jan 31, 2018, 6:11:29 AM | Anurag Srivastava

Top Blogs

Configure SonarQube Scanner with Jenkins

Jun 21, 2018, 4:58:11 AM | Anurag Srivastava

Build and deploy Angular code using Python

Jun 26, 2018, 4:50:18 PM | Anurag Srivastava

Configure Jenkins for Automated Code Deployment

Jun 13, 2018, 3:44:01 PM | Anurag Srivastava

SonarQube installation on Ubuntu

May 12, 2018, 4:47:07 PM | Anurag Srivastava

Execute Commands on Remote Machines using sshpass

Jul 16, 2018, 5:00:02 PM | Anurag Srivastava

Why SonarQube is important for IT projects ?

Apr 24, 2018, 2:52:28 PM | Anurag Srivastava

Wildcard and Boolean Search in Elasticsearch

Aug 10, 2018, 7:14:40 PM | Anurag Srivastava

Elasticsearch Rest API

Jul 31, 2018, 6:16:42 PM | Anurag Srivastava

Analyze your project with SonarQube

Jun 2, 2018, 10:49:54 AM | Anurag Srivastava

Configure Logstash to send MongoDB data into Elasticsearch

Mar 9, 2019, 8:20:38 AM | Anurag Srivastava