Skip to content

Instantly share code, notes, and snippets.

@franzwong
Last active November 19, 2022 16:13
Show Gist options
  • Save franzwong/c8d58c31387871389ac5fe0db8fb3fb4 to your computer and use it in GitHub Desktop.
Save franzwong/c8d58c31387871389ac5fe0db8fb3fb4 to your computer and use it in GitHub Desktop.
Run SonarQube on local machine

Run SonarQube on local machine

Build docker image for Mac M1

There is only amd64 docker image for SonarQube. We need to build by ourselves if we want to run it on Mac M1.

mkdir sonarqube_local
cd sonarqube_local
PROJECT_DIR=$(PWD)
mkdir -p sonarqube/data sonarqube/logs sonarqube/extensions
git clone [email protected]:SonarSource/docker-sonarqube.git
cd docker-sonarqube/9/community
git checkout 9.7.0
docker build -t sonarqube:9.7.0-community .

Start SonarQube

# Avoid hard termination of SonarQube by extending the stop timeout
docker run --stop-timeout 3600 -d \
--name sonarqube \
-v ${PROJECT_DIR}/sonarqube/data:/opt/sonarqube/data \
-v ${PROJECT_DIR}/sonarqube/logs:/opt/sonarqube/logs \
-v ${PROJECT_DIR}/sonarqube/extensions:/opt/sonarqube/extensions \
-p 9000:9000 \
-p 9092:9092 \
--ulimit nofile=131072 \
--ulimit nproc=8192 \
sonarqube:9.7.0-community

Web portal

URL: http://localhost:9000

User name: admin

Password: admin

After logged in, it will ask to change the password.

Generate token

  1. On the right top corner of web page, click the user icon
  2. Select "My account"
  3. Select "Security" tab
  4. Create a new token

Verify with maven

mvn clean verify sonar:sonar -Dsonar.login=<token>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment