Sonar is an open platform for code quality management.Through the plug-in mechanism, Sonar can integrate different testing tools, code analysis tools, and continuous integration tools.Unlike continuous integration tools such as Hudson/Jenkins, Sonar does not simply display the results of different code checking tools (such as FindBugs, PMD, etc.) directly on a Web page, but reprocesses them through different plug-ins to quantify changes in code quality, making it easy to measure changes in code quality at different sizes and typesThe project performs code quality management.
In support of other tools, Sonar not only provides IDE support, but also allows you to view results online in tools such as Eclipse and IntelliJ IDEA; Sonar also provides interface support for a number of continuous integration tools, making it easy to use Sonar in continuous integration.
In addition, Sonar's plug-ins support programming languages other than Java, internationalization, and document reporting.
1. Sonar Deployment
Sonar's related downloads and documentation can be found in the following links: http://www.sonarqube.org/downloads/ .It is important to note that the latest version of Sonar requires at least JDK version 1.8 and above.
[root@linux-node ~]# cd /usr/local/src/
#jdk needs to be downloaded from orcale's official website
#wget https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-5.6.7.zip
[root@linux-node src]# ls
jdk-8u121-linux-x64_.rpm sonarqube-5.6.7.zip
[root@linux-node src]# rpm -ivh jdk-8u121-linux-x64_.rpm
[root@linux-node src]# cat >> /etc/bashrc << END
export JAVA_HOME="/usr/java/jdk1.8.0_121"
END
[root@linux-node src]# source /etc/bashrc
[root@linux-node src]# echo ${JAVA_HOME}
/usr/java/jdk1.8.0_121
[root@linux-node src]# unzip sonarqube-5.6.7.zip
[root@linux-node src]# mv sonarqube-5.6.7 /usr/local/sonarqube
2. Database Authorization
mysql> create database sonar default character set 'utf8';
mysql> grant all on sonar.* to 'sonar'@'localhost' identified by 'sonar';
mysql> grant all on sonar.* to 'sonar'@'linux-node.example.com' identified by 'sonar';
mysql> grant all on sonar.* to 'sonar'@'%' identified by 'sonar';
mysql> flush privileges;
3. Configuring Sonar
[root@linux-node ~]# cd /usr/local/sonarqube/conf/
[root@linx-node conf]# ls
sonar.properties wrapper.conf
#Modify database configuration
[root@linx-node conf]# vim sonar.properties
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
4. Start Sonar
You can configure the IP address and port that Sonar Web listens on in Sonar's profile, defaulting to port 9000.
[root@linx-node conf]# vim sonar.properties
sonar.web.host=0.0.0.0
sonar.web.port=9000
[root@linx-node ~]# /usr/local/sonarqube/bin/linux-x86-64/sonar.sh start
5. Browser Access
Remarks:
Java Access Database Driver
Sonar has its own embedded database by default. If you are using an Oracle database, you must manually copy the driver to the ${SONAR_HOME}/extensions/jdbc-driver/oracle/directory. Other supported databases provide the driver by default.Other databases can be configured using official documentation:
http://docs.sonarqube.org/display/HOME/SonarQube+Platform