Skip to content

How to setup SonarQube Locally

Last updated on January 28, 2022

In this blog post, you will be going to learn how to set up the sonarqube locally. And Sonarqube can be used in any kind of project.

Overview

Basically, Sonarqube will help us to make sure about the source code quality and it can be configured based on the best practices.

Sonarqube.org

But, in the first place, you should understand what this blog post will help you. We have certain config settings in the sonarqube server which can be maintained only by the Admin people of the project.

But even you can impose the customized settings from the project itself which will be overridden the server settings. This local settings can be identified as sonar-project.properties file.

If in case, we want to try it out those settings locally before pushing the code changes and waiting for the build to get completed. This is the ideal situation here I would like to address.

How to setup SonarQube Locally


1. Sonarqube Server

Out of two ways, Work with the offline installation of Sonarqube with the Zip file which is quite challenging and is rely on Java Binaries, if you did setup properly you can execute the remaining steps locally. Whereas if you face any difficulties better please install Docker.

One more way is to install Dockerand go with Sonarqube Docker Imageto easily get started.

if you’ve preferred docker thing, you could use the below command to start the local sonarqube server.

> docker run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube:latest

Try out http://localhost:9000for the server.

2. Sonar Scanner

This step also requires us to install either a local version installer or using Docker Image as the previous step. It’s better to use docker.

You will be required to create a project from the http://localhost:9000running server. But before hand it will ask you to create a auth token. That’s completely your choice.

Please be make a note the project name and the auth token.

If docker image setup is preferred, then use the below command to start the scanner.

> sonar-scanner -Dsonar.login=<AUTH_TOKEN>

<AUTH_TOKEN> must be replaced by auth token value.

3. Sonar Properties

This can be represented by a file that will have the project-based settings against Sonarqube. Ideally, this file would look like this,

sonar.projectKey=corengwidgets
sonar.projectVersion=1.0
sonar.sources=<Source Directory>


That’s all about it! You can always share your opinion below in order to keep this blog post as quality as possible.

Published inGeneralJavaScript