Set up SonarQube Server Locally.

Sadil Chamishka
2 min readOct 8, 2019

--

SonarQube provides continuous inspection of code quality to perform automatic reviews with static analysis of code to detect bugs, code smells, and security vulnerabilities on 20+ programming language

you can download the community edition from here. It supports for the system with Java 11 support.

you can keep the sonarqube files inside /opt/sonarqube.

You can see inside the conf directory, sonnar.properties file can be used to configure the SonarQube server.

Ex: port number, database configurations for user management.

There are separate directories inside the bin folder for Windows, Linux and Mac Operating systems, to start the SonarQube server. By executing the shell script, you can start the server.

./sonar.sh 

You will be prompted to provide another command like this

./sonar.sh start

Also, you can check status, stop the server. By default, the server is started on port 9000.

You can get a detailed analysis of your corresponding projects through the SonarQube server as follows.

Let’s create a maven project and integrate it with the SonarQube scanner to get the reports. We have to add this dependency in pom.xml file

<dependency>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.2</version>
</dependency>

Also, add this Profile in the pom.xml

<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<sonar.host.url>
http://192.168.2.174:9000
</sonar.host.url>
</properties>
</profile>
</profiles>

You can use this command to get the Sonnar reports from SonarQube.

mvn sonar:sonar

You can view the code here.

--

--

Sadil Chamishka
Sadil Chamishka

Written by Sadil Chamishka

Associate Technical Lead @ WSO2 IAM TEAM

No responses yet