Skip to content

Run Sonar Locally

Damien Gallagher edited this page Jul 5, 2021 · 4 revisions

Run Sonar Locally

Approach 1

  1. Navigate to the app directory
  2. To run the Sonar docker image, execute the following command

docker-compose -f src/main/docker/sonar.yml up -d

  1. Sonar is now available at the url http://localhost:9001
  2. Login to Sonar. Default username is admin and default password is admin
  3. You will be asked to change the default password.
  4. As you can see, there are no projects available. To analyze the SmallWindow21 project - execute the following command ./mvnw -Pprod clean verify sonar:sonar
  5. When that command completes successfully, you will be able to see the Sonar results at the page http://localhost:9001/projects

Approach 2

  1. Navigate to the app directory and then the scripts directory
  2. Execute the script Run Sonar Analysis.bat or Run Sonar Analysis.sh if running on Linux or Mac
  3. This scripts starts the Sonar docker image and executes the Sonar analysis. It is just a convenience method.

Re execute Sonar Anaylsis

Note: Sonar should already be running

Approach 1

  1. Navigate to the app directory
  2. Execute the following command ./mvnw initialize sonar:sonar

Approach 2

  1. Navigate to the app directory and then the scripts directory
  2. Execute the script ReRun Sonar Analysis.bat or ReRun Sonar Analysis.sh if running on Linux or Mac
  3. This scripts re runs the Sonar Analysis. It is just a convenience method.