1. Requirements
Hardware Requirements: The SonarQube webserver requires at least 500 Mb of RAM to run efficiently
Supported Platforms: Oracle JRE/ MySQL/ MozillaFirefox、GoogleChrome
2. Platform Overview
One Database to store: the configuration ofthe SonarQube instance (security, plugins settings, etc.)the quality snapshotsof projects, views, etc.
One Web Server for users to browse qualitysnapshots and configure the SonarQube instance
One ormore Analyzers to analyze projects
3. Installing theDatabase
sudo apt-getinstall mysql-server
Execute sql:
CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'sonar' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
FLUSH PRIVILEGES;
4. Edit sonar.properties
#self jdbcdefault
sonar.jdbc.url=
sonar.web.host=192.168.131.20
sonar.web.port=9000
sonar.web.context=/sonar
5. Tuning the WebServer
By default, SonarQube is configured to run onany computer with a simple Java JRE. For better performance, the first thing todo when installing a production instance is to use a Java JDK and activate theserver mode by uncommenting the following line in
wrapper.java.additional.X=-server
6. add plugin folder
download it into the SONARQUBE_HOME/extensions/plugins directory
7. start sonar
bin/linux-x86-64/sonar.sh start(restart/stop)
8. Running SonarQube as a Service on Linux
Create the file/etc/init.d/sonar with this content:
#!/bin/sh
#
# rc file forSonarQube
#
# chkconfig: 34596 10
# description:SonarQube system (www.sonarsource.org)
#
### BEGIN INITINFO
# Provides: sonar
# Required-Start:$network
# Required-Stop:$network
# Default-Start:3 4 5
# Default-Stop: 01 2 6
#Short-Description: SonarQube system (www.sonarsource.org)
# Description:SonarQube system (www.sonarsource.org)
### END INIT INFO
/usr/bin/sonar $*
sudo cp xx/sonar/etc/init.d
RegisterSonarQube at boot time (Ubuntu, 32 bit):
sudo ln -s$SONAR_HOME/bin/linux-x86-64/sonar.sh /usr/bin/sonar
sudo chmod 755/etc/init.d/sonar
sudo update-rc.dsonar defaults
9. Installation sonar-runner
Uncompress thedownloaded file, editing
sonar.jdbc.url=
sonar.host.url=
10. sudo gedit /etc/environment
Create a newSONAR_RUNNER_HOME environment variable set to
:/home/qinzhonghua/sonar/sonar-runner-2.4/bin
export SONAR_RUNNER_HOME=/home/qinzhonghua/sonar/sonar-runner-2.4
export SONAR_RUNNER_OPTS="-Xmx512m-XX:MaxPermSize=128m"
source/etc/environment
You can check the basic installation byopening a new shell and executing the command “sonar-runner –h”
11. analyzingprojects
Create a configuration file in the rootdirectory of the project: sonar-project.properties
# Requiredmetadata
sonar.projectKey=my:project
sonar.projectName=Myproject
sonar.projectVersion=1.0
# Path to theparent source code directory.
# Path isrelative to the sonar-project.properties file. Replace "\" by"/" on Windows.
# Since SonarQube4.2, this property is optional. If not set, SonarQube starts looking for sourcecode
# from thedirectory containing the sonar-project.properties file.
sonar.sources=src
# Encoding of thesource code
sonar.sourceEncoding=UTF-8
# Additionalparameters
sonar.my.property=value
sonar.skipPackageDesign=true
sonar.profile=AndroidLint
If you get a Javaheap space error or java.lang.OutOfMemoryError, you can increase the memory viathe SONAR_RUNNER_OPTS environment variable:
exportSONAR_RUNNER_OPTS="-Xmx512m -XX:MaxPermSize=128m"
12. analyzing android project
The ANDROID_HOMEenvironment variable should be configured to point to the installationdirectory of the Android SDK.
/etc/environment
exportANDROID_HOME=/home/qinzhonghua/eclipse/sdk
13. sonar.skipPackageDesign=true
If some code use other library, but you do notimport it ,you can use “sonar.skipPackageDesign=true”
14. Analysis Parameters
http://docs.codehaus.org/display/SONAR/Analysis+Parameters
15. setup eclipseplugin
http://dist.sonar-ide.codehaus.org/eclipse
select sonar-java