installation, configuration and use of Sonarqube

Source: Internet
Author: User

Sonarqube is an open platform for managing code quality that can quickly locate potential or obvious errors in your code, and will describe the installation, configuration, and use of this tool.

preparatory work;

1, JDK (no longer introduced)

2, sonarqube:http://www.sonarqube.org/downloads/

3, Sonarqube+scanner:https://sonarsource.bintray.com/distribution/sonar-scanner-cli/sonar-scanner-2.5.zip

4. mysql database (no longer introduced)

First, install the article

1. After downloading the Sonarqube, unpack to open the Bin directory and launch the Startsonar in the appropriate OS directory. If this article demonstrates the use of a win 64-bit system, open the D:\sonar\sonarqube-5.3\sonarqube-5.3\bin\windows-x86-64\StartSonar.bat

2. Launch the browser, Access http://localhost:9000, if it appears, the installation is successful.

Second, the configuration chapter

1. Open MySQL and create a new database.

2. Open the D:\sonar\sonarqube-5.3\sonarqube-5.3\conf\sonar.properties file in the Sonarqube installation directory

3. In MySQL5. Enter the following information under the X node

Sonar.jdbc.url=jdbc:mysql://172.16.30.228:3306/qjfsonar?useunicode=true&characterencoding=utf8 &rewritebatchedstatements=true&useconfigs=maxperformancesonar.jdbc.username=  gmsdsonar.jdbc.password=gmsdtradesonar.sorceencoding=utf-8sonar.login=adminsonar.password= Admin      

URL is the database connection address, username is the database user name, Jdbc.password is the database password, login is sonarqube login name, Sonar.password is sonarqube password

4. Restart the Sonarqube service, Access http://localhost:9000 again, a little bit slower because the database information is initialized

5. After the database has been initialized successfully, log in

6. Follow the click order to enter the plugin installation page

7. Search Chinese Pack, install the Chinese language pack

8. After successful installation, restart the Sonarqube service and visit http://localhost:9000/again to see the Chinese interface

Iii. use of the article

1. Open D:\sonar\sonar-scanner-2.5\conf\sonar-runner.properties File

Enter the following information under the 2.mysql node

Sonar.jdbc.url=jdbc:mysql://172.16.30.228:3306/qjfsonar?useunicode=true&characterencoding=utf8 &rewritebatchedstatements=true&useconfigs=maxperformancesonar.jdbc.username=  Gmsdsonar.jdbc.password=gmsdtrade  

Note: If the test project is not on the same machine as the server, you need to add the server's IP:

#----- Default SonarQube serversonar.host.url=http://xxx.xxx.xxx.xxx:9000  

3. Configure Environment variables

A. Create a new variable, name=sonar_runner_home. value=d:\sonar\sonar-scanner-2.5

B. Open path and enter%sonar_runner_home%\bin;

C.sonar-runner-version, the following message appears, indicating that the environment variable is set successfully

4. Open the project root directory for code analysis and create a new sonar-project.properties file

5. Enter the following information

# must be uniqueInchA given SonarQube instancesonar.projectkey=my:project#Thisis the name displayedInchThe SonarQube uisonar.projectname=apiautocoresonar.projectversion=1.0# Pathis relative to the sonar-project.properties file. Replace"\ "by"/" on windows.# Since SonarQube 4.2, this Property is 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=SRC # Encoding of the source code. Default is default system Encoding#sonar.sourceencoding=utf-8       

Where: ProjectName is the project name, sources is the directory where the source file resides

6. After the setup is successful, start the Sonarqube service and start cmd

7. In cmd enter the root directory where the project is located, enter the command: Sonar-runner, the analysis will appear after successful

8. Open the http://localhost:9000/and we'll see a schematic of the analysis item on the homepage

9. We click on the project, select the problem link, you will see the analysis of the code bug, Wow, a lot of

10. Select one of the most serious bugs to see

It turns out that there is a null pointer exception in this place because I'm using this variable without initializing it. Over

For more information, please visit the website to learn from it.

http://www.sonarqube.org/

Http://docs.sonarqube.org/display/SONAR/Analyzing+with+SonarQube+Scanner

installation, configuration and use of Sonarqube

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.