First, after the installation of the Sonarqube server, on the other Computer browser landing, began to install other programming language detection plug-in
650) this.width=650; "title=" image "style=" border-right-width:0px;background-image:none;border-bottom-width:0px; padding-top:0px;padding-left:0px;padding-right:0px;border-top-width:0px; "border=" 0 "alt=" image "src=" http:// S3.51cto.com/wyfs02/m01/89/13/wkiom1gg7alqv7knaacq0rhva1k861.png "width=" 1093 "height=" 672 "/>
650) this.width=650; "title=" image "style=" border-right-width:0px;background-image:none;border-bottom-width:0px; padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; "border=" 0 "alt=" image "src=" Http://s3.51cto.com/wyfs02/M00/89/10/wKioL1gG7APgTNNLAAECchzKu3s111.png "width=" 1079 "height=" 660 "/>
The system has installed the language plugin:
650) this.width=650; "title=" image "style=" border-right-width:0px;background-image:none;border-bottom-width:0px; padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; "border=" 0 "alt=" image "src=" Http://s3.51cto.com/wyfs02/M02/89/10/wKioL1gG7AWB_VtNAAEWsJ2QN3U317.png "width=" 1078 "height=" 664 "/>
650) this.width=650; "title=" image "style=" border-right-width:0px;background-image:none;border-bottom-width:0px; padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; "border=" 0 "alt=" image "src=" Http://s3.51cto.com/wyfs02/M00/89/13/wKiom1gG7AfiN_2HAAGQSl0l7hA667.png "width=" 1079 "height=" 660 "/>
Downloaded the languages commonly used in software projects:Android,CSS,Web,XML
Java Related:Checkstyle,Findbugs,PMD
Java Static analysis Tool analysis objects |
Application |
Checkstyle |
Java source files, bug pattern matching |
Findbugs |
Byte code, defect pattern matching, data stream analysis |
Pmd |
Java source code, bug pattern matching |
After downloading the parsing language rules, restart the service
650) this.width=650; "title=" image "style=" border-right-width:0px;background-image:none;border-bottom-width:0px; padding-top:0px;padding-left:0px;margin:0px;padding-right:0px;border-top-width:0px; "border=" 0 "alt=" image "src=" Http://s3.51cto.com/wyfs02/M02/89/13/wKiom1gG7AnDT0TNAAFGj3TKGOs414.png "width=" 1077 "height=" 667 "/>
Second, install the command line analysis side
Sonar's command-line analysis software has two runner and scanner, the official document is written in scanner, but runner and its installation, use is basically the same.
1. Install sonar-runner-dist-2.4 on CentOS
cd/usr/local/src/
wget Http://repo1.maven.org/maven2/org/codehaus/sonar/runner/sonar-runner-dist/2.4/sonar-runner-dist-2.4.zip
Unzip Sonar-runner-dist-2.4.zip
MV sonar-runner-2.4//usr/local/
Vim/etc/profile
At the end of the file, add the following, save and exit.
Path= $PATH:/usr/local/sonar-runner-2.4/bin
Export PATH
Vim/usr/local/sonar-runner-2.4/conf/sonar-runner.properties
Remove or add the following # before you save and exit
Sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useunicode=true&characterencoding=utf8
Sonar.jdbc.username=sonar
Sonar.jdbc.password=sonar
sonar.host.url=http://192.168.1.190
Sonar.login=admin
Sonar.password=admin
After the installation is successful, restart the server, run the above command at the command line and echo it, indicating that the operation was successful.
[Email protected] local]# sonar-runner-h
INFO:
Info:usage:sonar-runner [Options]
INFO:
Info:options:
INFO:-D,--define <arg> define Property
INFO:-e,--errors produce execution error messages
INFO:-H,--help Display Help information
INFO:-V,--version Display version information
INFO:-x,--debug produce execution debug output
2. Install sonar-scanner2.8 on CentOS
cd/usr/local/src/
wget Https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-2.8.zip
Unzip Sonar-scanner-2.8.zip
MV sonar-scanner-2.8//usr/local/
Vim/etc/profile
At the end of the file, add the following, save and exit.
Path= $PATH:/usr/local/sonar-runner-2.4/bin:/usr/local/sonar-scanner-2.8/bin
Export PATH
Vim/usr/local/sonar-scanner-2.8/conf/sonar-scanner.properties
Remove or add the following # before you save and exit
Sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useunicode=true&characterencoding=utf8
Sonar.jdbc.username=sonar
Sonar.jdbc.password=sonar
sonar.host.url=http://192.168.1.190
Sonar.login=admin
Sonar.password=admin
After the installation is successful, restart the server, run the above command at the command line and echo it, indicating that the operation was successful.
[Email protected] local]# sonar-scanner-h
INFO:
Info:usage:sonar-scanner [Options]
INFO:
Info:options:
INFO:-D,--define <arg> define Property
INFO:-H,--help Display Help information
INFO:-V,--version Display version information
INFO:-x,--debug produce execution debug output
INFO:-I,--interactive Run interactively
C. Package the source code of the development program into a ZIP file and upload it to a server with runner or scanner installed
650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt=" image "src=" Http://s3.51cto.com/wyfs02/M00/89/13/wKiom1gG7AyC0hQ3AAHuasZl-Js249.png "height=" 748 "/>
Unzip the uploaded source code:
cd/usr/local/
Unzip Whale.zip
Iv. using Sonar-scanner for code quality analysis
1. Create a configuration file on the server that is ready to be executed with scanner
CD whale/
Vim Sonar-project.properties
2, the establishment of the contents of the document as follows:
# must is unique in a given SonarQube instance
sonar.projectkey=Whale:scanner
# This is the name and version displayed in the SonarQube UI. was mandatory prior to SonarQube 6.1.
Sonar.projectname=Whale-scanner
sonar.projectversion=1.0
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Since SonarQube 4.2, this is the optional if Sonar.modules is set.
# If not set, SonarQube starts looking for source code from the directory containing
# The Sonar-project.properties file.
Sonar.sources=.
# Encoding of the source code. Default is default system encoding
#sonar. Sourceencoding=utf-8
3, save and exit after running the command for analysis (analysis can not perform Findbugs3.4.3 analysis, the web-side uninstall this rule after the normal analysis):
Sonar-scanner
4. View the results of scanner code quality analysis in the Web.
650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" image "src=" http:// S3.51cto.com/wyfs02/m01/89/13/wkiom1gg7a7irtvaaae14gi2lzo261.png "height=" 880 "/>
V. Using Sonar-runner for Code quality analysis
1. Modify the configuration file under Scanner execution
cd/usr/local/whale/
Vim Sonar-project.properties
2. The contents of the modified file are as follows:
# must is unique in a given SonarQube instance
sonar.projectkey=Whale:runner
# This is the name and version displayed in the SonarQube UI. was mandatory prior to SonarQube 6.1.
Sonar.projectname=Whale-runner
sonar.projectversion=1.0
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Since SonarQube 4.2, this is the optional if Sonar.modules is set.
# If not set, SonarQube starts looking for source code from the directory containing
# The Sonar-project.properties file.
Sonar.sources=.
# Encoding of the source code. Default is default system encoding
#sonar. Sourceencoding=utf-8
3, save and exit after running the command for analysis (analysis can not perform Findbugs3.4.3 analysis, the web-side uninstall this rule after the normal analysis):
Sonar-runner
4. View the results of runner Code quality analysis in the Web.
650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt=" image "src=" Http://s3.51cto.com/wyfs02/M01/89/10/wKioL1gG7A_C24xiAAE-vS5vSEU518.png "height=" 904 "/>
As a result, the runner and scanner functions are similar.
This article from the "Strong Technical communication blog," Please be sure to keep this source http://newthink.blog.51cto.com/872263/1863334
Sonar6.0 Application II: Sonar Web Interface Configuration and runner, scanner integration for command line code analysis