Sonarqube server & scanner scripts using the dockerized versions
- bash
- docker
Installing in the /opt/sonar
directory.
# Since /opt is a system dir, execute the commands as root
sudo su
# Clone the project in the target directory
cd /opt
git clone https://github.com/yannoff/sonar
# Optionally create symlinks to allow system-wide script evocation
cd /usr/bin
ln -s /opt/sonar/bin/server sonar-server
ln -s /opt/sonar/bin/scan sonar-scan
-
Start the server
# Start the sonarqube server /opt/sonar/bin/server start # Watch the server logs an wait until bootstrap complete /opt/sonar/bin/server log
-
Visit the sonarqube local website at
http://localhost:9999
Default credentials for the first connection:
- username:
admin
- password:
admin
- username:
-
Create a new key and token to use with the project to scan
-
Launch the scanner from the local project directory, using the previously created key and token
Example
/opt/sonar/bin/scan --sources=src/ --project=acme:key --login=1e3a987cde65fdd74118
The following options may be used to override the sonar-scanner
defaults or the settings defined in the sonar-project.properties
file.
The project key.
Path to the project sources.
The project token.
Alternative host for the sonarqube server. (defaults: sonar-server)
Alternative port for the sonarqube server. (defaults: 9999)
Additional settings may be configured via the .sonarrc
file.
Variable | Description | Default |
---|---|---|
SONAR_HOME |
Top-level dir for the server data storage | $(dirname .sonarrc)/var |
SONAR_PORT |
Listening port for the sonar server (both internal & exposed) | 9999 |
SONAR_HOST |
Hostname for the sonar server docker service | sonar-server |
SONAR_NETWORK |
Network name for the sonar server docker service | sonar |
Licensed under the MIT License.