Continuous detection of code using Jenkins and Sonar integration

Source: Internet
Author: User
Tags comments mysql database

Sonarqub E and J Enkin s Introduction

Sonarqub e is an open source code quality analysis platform that facilitates the management of code quality, and examines the vulnerabilities and potential logic issues of project code. At the same time, it provides a rich number of plug-ins to support the detection of multiple languages, such as J Ava, Python, Groovy, C, C + +, and other dozens of programming languages. Its main core values are shown in the following areas: Check if code follows programming standards: Naming conventions, writing specifications, etc. Check for potential flaws in the design: Sonarqub e detects flaws in the code through tools such as plug-ins F indbugs, Checkstyl E. Duplicate code volume for instrumented code: SONARQUB e can show a large amount of copy-and-paste code in your project. Detect the extent of comments in the code: too many or too few source comments are not good, affecting the program's readable and understandable. Detect the relationships between packages and classes in code: Analyze whether the relationships between classes are reasonable and complex.

The Sonarqub e platform is comprised of 4 parts: SonarQube Server SonarQube Database SonarQube Plugins SonarQube Scanner SonarQube with Sonar Installation and configuration of Qube-scanner SonarQube

In the S Onarqub E official website, we can download the latest S Ona r installation package, this section with L Inu X system For example, build S Onarqub e platform, extract to any directory, such as: Unzip Sonarqube5.6.zip.

Sonarqub e comes with a H2 database, of course, to get better performance we can specify an external database, where we use MySQL database. An S ona R database is established in M ysq L database, which is mainly used to store the data of analysis results, as shown in Figure 1: Figure 1. Creating a MySQL database

Enter the extracted S onarque b directory, in the system path with a good P ATH, configured as follows:

1 2 3) 4 5 #sonar profile Export sonar_home=/usr/local/sonarqube-5.6.1 export Path=${sonar_ho Me}/bin:${path}

and modify the configuration file S onar.properties as follows:

1 2 3 4 5 6 7 # sonar.jdbc.username=root #sonar. Jdbc.password=root #sonar. Jdbc.url=jdbc:mysql://localhost:3306/sonar? useunicode=true&characterencoding= Utf8&rewritebatchedstatements=true&useconfigs=maxperformance # Option Properties Sonar.jdbc.driverClassName:com.mysql.jdbc.Driver

Basic configuration complete, start S Onarqube at command line: Enter s Onarqub e installation directory, enter b i n directory, run./sonar.sh start, open H ttp://localhost:9000, if show S Onar Qub e Home page, the S Onarqub e installation was successful. As shown in Figure 2. Figure 2. SonarQube Start Page

If you need to close S Onarqube, execute the./sonar.sh stop

If you need to restart S onarqube, execute./sonar.sh restart SonarQube Scanner

Download S onar-scanner-2.6.1, unzip to the directory (can be extracted to any directory). Modify the system path P ATH, as follows:

1 2 3 4

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.