Skip to content

Instantly share code, notes, and snippets.

@hardyscc
Last active January 16, 2026 10:12
Show Gist options
  • Select an option

  • Save hardyscc/1ab4959ef82b5be0ee902840d617f320 to your computer and use it in GitHub Desktop.

Select an option

Save hardyscc/1ab4959ef82b5be0ee902840d617f320 to your computer and use it in GitHub Desktop.

Self-hosted Sonarqube

Start Docker Instance

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

Generate Token

  1. Goto http://localhost:9000 login as admin/admin, then change password
  2. Goto http://localhost:9000/admin/users, click on Update Tokens and create a default token.

Run Sonar Scanner

Maven

Simple

./mvnw clean verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.host.url=http://localhost:9000 -Dsonar.token=<your-default-token>

Preferred

Add following into ~/.m2/settings.xml

<pluginGroups>
    <pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
</pluginGroups>

Add Environments

export SONAR_TOKEN=<your-default-token>
export SONAR_HOST_URL=http://localhost:9000
./mvnw clean verify sonar:sonar

NPM

npx sonarqube-scanner -Dsonar.host.url=http://localhost:9000 -Dsonar.token=<your-default-token>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment