Skip to content

Instantly share code, notes, and snippets.

@marek-panek
Last active May 9, 2024 18:34
Show Gist options
  • Save marek-panek/8b5fec0ad623926b110267e0b7d66559 to your computer and use it in GitHub Desktop.
Save marek-panek/8b5fec0ad623926b110267e0b7d66559 to your computer and use it in GitHub Desktop.
SonarQube configuration with PostgreSQL
1. In PostgreSQL database
1.1 Create user
create user <user_name> with password '<password>';
1.2 Create database
create database <db_name> with owner <user_name> encoding 'UTF8';
2. Edit <sonar_install_dir>/conf/sonar.properties
sonar.jdbc.username=<user_name>
sonar.jdbc.password=<password>
sonar.jdbc.url=jdbc:postgresql://localhost/<db_name>
sonar.web.host=0.0.0.0
# Web context. When set, it must start with forward slash (for example /sonarqube).
sonar.web.context=/sonarqube
# TCP port for incoming HTTP connections. Default value is 9000.
sonar.web.port=9999
3. Open port
sudo iptables -A INPUT -p tcp --dport 9999 -j ACCEPT
4. Run SonarQube with <sonar_install_dir>/<so_env>/bin/sonar.sh
5. Login as admin and generate token
6. You can use it with maven:
mvn sonar:sonar -Dsonar.host.url=http://<host>:<port>/<web_context> -Dsonar.login=<generated_token>
To exclude for example JS files add -Dsonar.exclusions=**/*.js to the above command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment