How to setup sonarqube analysis code

Posted on March 18th, 2023

Setup Sonarqube for MacOS

Pre request:

Docker pull sonarqube

docker run -d --name sonarqube -p 9000:9000 -p 9092:9092 sonarqube


docker run -d --name sonarqube -p 9000:9000 -p 9092:9092 -e SONARQUBE_JDBC_USERNAME=sonar -e SONARQUBE_JDBC_PASSWORD=sonar -e SONARQUBE_JDBC_URL=jdbc:postgresql://localhost/sonar sonarqube

Start Sonarqube

docker start sonarqube

How to use Sonarqube

Access to http://localhost:9000 Login with username & password = admin

1. Create new project & Generate token
2. Download sonar scanner:

and then unzip the file & move to /Users/xxx

Open /Users/xxx/.zshrc and add the bin directory to the PATH environment variable

 export PATH="$PATH:$HOME/sonar-scanner/bin"
3. Running a SonarQube analysis

cd to root project and run command:

sonar-scanner \
  -Dsonar.projectKey=test \
  -Dsonar.sources=. \ \