SonarQube
SonarQube is code quality tool for better code and published under the LGPL3 license.
Installation
Install the sonarqube-binAUR package.
SonarQube uses H2 database by default (not recommended). Or requires the use of a database backend, the following are supported:
- MariaDB/MySQL
- PostgreSQL
- Oracle
- MSSQL
Configuration
The user configuration file is located at /etc/webapps/sonarqube/sonar.properties
.
See the SonarQube docs for more configuration examples.
PostgreSQL
Install and configure PostgreSQL.
SonarQube seems to support only TCP Socket
With TCP socket
Connect do postgresql:
[postgres]$ psql
Create the new user while connecting to the server as postgres
user (you will be prompted for a password for the new user):
postgres=# CREATE USER sonarqube WITH PASSWORD password;
Create the Gitea database, owned by gitea
user:
postgres=# CREATE DATABASE sonarqube OWNER sonarqube; postgres=#GRANT ALL PRIVILEGES ON DATABASE sonarqube TO sonarqube;
PostgreSQL#Configure PostgreSQL to be accessible from remote hosts
Verify it works:
$ psql --host=ip_address --dbname=sonarqube --username=sonarqube --password
Configure SonarQube through the update sonar.properties
:
/etc/webapps/sonarqube/sonar.properties
sonar.jdbc.url=jdbc:postgresql://localhost/sonarqube sonar.jdbc.username=sonarqube sonar.jdbc.password=password sonar.web.javaOpts=-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError sonar.web.javaAdditionalOpts=-server sonar.web.host=0.0.0.0 sonar.web.port=9000 sonar.log.level=INFO sonar.path.logs=logs
Upgrade
After upgrading SonarQube, follow these steps:
- Update the
sonar.properties
file to match the new version. - Once SonarQube is running, a page will appear prompting you to upgrade. For detailed instructions, visit the upgrade guide.
- Navigate to the setup page of your SonarQube server at
https://ip:port/setup
and click the upgrade button. - Once the upgrade process is complete, the normal login page will be displayed.
Usage
Start/enable sonarqube.service
, the webinterface should listen on http://localhost:9000
.
Default credentials are admin/admin
.
- You might want to configure a reverse proxy to access remotely, e.g. nginx.
- If you want Sonarqube to not listen on all interfaces, set
sonar.web.host
to e.g. 127.0.0.1 in/etc/webapps/sonarqube/sonar.properties
.
Usage with maven
$ mvn clean verify sonar:sonar -Dsonar.projectKey=project key -Dsonar.projectName=project -Dsonar.host.url=http://localhost:9000 -Dsonar.token=token
Usage with sonar-scanner
There is a package sonar-scannerAUR. Usage is:
$ /opt/sonar-scanner/bin/sonar-scanner -Dsonar.projectKey=project key -Dsonar.sources=. -Dsonar.host.url=http://localhost:9000 -Dsonar.token=token
Troubleshooting
You can check the unit status or the journal.
And there are sonarqube logs in:
# /var/log/sonarqube/
If sonarqube is not active, one of these logs will contain an error.