SonarQube code quality management tool environment preparation notes

Source: Internet
Author: User

SonarQube code quality management tool environment preparation notes

SonarQube code quality management tool environment building notes

Put your technical debt under control
Productivity is falling?
Confess your source code to clean it up!

Step 1: Install SONAR

1. Prepare the JAVA environment.
2. Create an Oracle tablespace and a user.
2. download the latest sonar and decompress it to the directory C: \ app \ sonar-3.6.
3. Modify C: \ app \ sonar-3.6 \ conf \ sonar. properties:
Sonar. jdbc. username: sonar
Sonar. jdbc. password: sonar
Sonar. jdbc. url: jdbc: oracle: thin: @ localhost: 1521/orcl
Sonar. jdbc. driverClassName: oracle. jdbc. driver. OracleDriver

4 run C: \ app \ sonar-3.6 \ bin \ windows-x86-64 \ StartSonar. bat (windows server 2008 operating system) to start the built-in JETTY server. Open http: // localhost: 9000. If the sonar homepage is displayed, the sonar installation is successful.
5. Install the Chinese plug-in and other language plug-ins: place the plug-in JAR package in the directory C: \ app \ sonar-3.6 \ extensions \ plugins. Restart the service to install the plug-in successfully.
Chinese Plugin: sonar-l10n-zh-plugin-1.5
JS language: sonar-javascript-plugin-1.3
Web (HTML): sonar-web-plugin-1.2
6 Add the database driver to C: \ app \ sonar-3.6 \ extensions \ jdbc-driver \ oracle \ ojdbc-14.jar

Step 2: Install SONAR-RUNNER

1. Download sonar-runner and decompress it to the C: \ app \ sonar-runner-2.2.2 directory.
2 modify C: \ app \ sonar-runner-2.2.2 \ sonar-runner.properties:
Sonar. jdbc. url = jdbc: oracle: thin: @ localhost: 1521/orcl
Sonar. jdbc. username = sonar
Sonar. jdbc. password = sonar
Sonar. sourceEncoding = UTF-8
Sonar. login = admin
Sonar. password = admin


3. Add the system environment variable SONAR_RUNNER_HOME. The value is C: \ app \ sonar-runner-2.2.2.
4. Modify the Path of the environment variable and add "; % SONAR_RUNNER_HOME % \ bin" at the end of the variable value"
5. Execute sonar-runner-h in the command line. If the following content is displayed, the installation is successful.
C: \ app \ sonar-runner-2.2.2
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

 

Step 3: analyze the code
1. Copy the code to C: \ workspase \ xjglxt.
Code directory structure

 

2 add C: \ workspase \ xjglxt \ sonar-project.properties content as follows:
# Required metadata
# Unique ID of the projectKey project, which cannot be repeated
Sonar. projectKey = xjglxt
Sonar. projectName = xjglxt
Sonar. projectVersion = 1.0
Sonar. sourceEncoding = UTF-8
Sonar. modules = java-module, javascript-module, html-module

# Java module
Java-module.sonar.projectName = Java Module
Java-module.sonar.language = java
#. Indicates the directory specified by projectBaseDir
Java-module.sonar.sources =.
Java-module.sonar.projectBaseDir = src
Sonar. binaries = classes

# JavaScript module
Javascript-module.sonar.projectName = JavaScript Module
Javascript-module.sonar.language = js
Javascript-module.sonar.sources = js
Javascript-module.sonar.projectBaseDir = webRoot

# Html module
Html-module.sonar.projectName = Html Module
Html-module.sonar.language = web
Html-module.sonar.sources = pages
Html-module.sonar.projectBaseDir = webRoot

 

3. Run cd ../workspase/xjglxt in the command line to go to the project root directory.
Run the sonar-runner command to print the analysis process on the console. When SUCCESS occurs, the analysis is successful.
INFO :--------------------
INFO: EXECUTION SUCCESS
INFO :--------------------
Total time:. 891 s
Final Memory: 14 Mb/449 MB
INFO :--------------------

Official Website: http://www.sonarqube.org/
Example: http://nemo.sonarsource.org/
Documents & plug-ins: http://docs.codehaus.org/

Problems and Solutions:
1 problem: the project list contains only the projects that were last analyzed.
Cause: the same value is set for sonar. projectKey.
2. garbled characters are displayed when the project name is set to Chinese (sonar. projectName = Chinese)
Cause: not found

Configure Sonar and Jenkins for continuous review

Use Sonar for code Quality Management

Sonar details: click here
Sonar: click here

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.