Analyse a project with SonarQube
SonarQube measures code smells, coverage, duplications and many more metrics for a wide range of languages. This guide sets up a local SonarQube server, scans a project with it and imports the results into a CodeCharta map with the Sonar Importer. If your team already runs a SonarQube server, skip to Import the metrics.
Start a local SonarQube server
Section titled “Start a local SonarQube server”With Docker
Section titled “With Docker”docker run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube:latestSee the SonarQube image on Docker Hub for other versions and settings.
From the zip file
Section titled “From the zip file”- Download SonarQube and unzip it.
- Start the server with
bin\windows-x86-64\StartSonar.baton Windows orbin/<os>/sonar.sh starton Linux and macOS, from the folder you unzipped.
Either way, open localhost:9000 in your browser and log in as admin with the password admin. SonarQube asks
you to change the password on the first login.
Install SonarScanner
Section titled “Install SonarScanner”- Download SonarScanner CLI and unzip it.
- Add its
binfolder to yourPATH.
Scan the project
Section titled “Scan the project”- In SonarQube, create a project and give it a project key and a display name.
- Generate a token and pick the main language of the project.
- Run the
sonar-scannercommand SonarQube shows you from the root folder of your project.
Create a user token
Section titled “Create a user token”The Sonar Importer needs a user token. Create one under your account, in the Security settings.

Import the metrics
Section titled “Import the metrics”ccsh sonarimport http://localhost:9000 <project-key> --user-token=<user-token> -o project.sonar.cc.jsonThis writes project.sonar.cc.json.gz. Add -m with a comma-separated list to import only some metrics, and
--merge-modules for a multi-module project. To see the Sonar metrics next to the history, merge the file with the
result of other commands using the Merge Filter.
Related
Section titled “Related”- Sonar Importer
- Analysis examples
- simplecc.sh: scans and imports in one script