Continuous integrated Jenkins+sonarqube Deployment Tutorial __jenkins

Source: Internet
Author: User
Tags pack create database checkstyle
an overview

This article mainly introduces the installation and integration of Jenkins,sonarqube, code analysis has Sonarqube and sonar-runner build, or in the case of MAVEN project can sonarqbude and maven build. Describes the Jenkins compilation package deployment, code checking. Finally integrated Jenkins two pre-installed software

Software name Platform notes jdk1.8.0_60 Win10 operating system apache-tomcat-8.0.20 Win10 Tomcat container Jenkins Win10 Port 8088 sonarqube-6.2 Port Win10 nar-runner-2.6.1 Win10 mysql 5.6 Win10 nexus-3.2.0-01 Linux maven Private service three configuration environment variables

The environment variable method that configures each software does not expand the description. In addition to Nexus, the rest are installed locally.



Four Sonarqube installation

4.1 Extract the Sonaeqbude to the local area.

Modify the Sonar.properties file. The database uses local MySQL to create a library called Sonar.

The table is created automatically when the Sonarqube is started.

Build the database statement JS Code CREATE database sonar CHARACTER SET UTF8 COLLATE utf8_general_ci; Add the following content, sonar default with MySQL driver. JS code sonar.jdbc.username=root sonar.jdbc.password=11111 Sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar? Useunicode=true&characterencoding=utf8&rewritebatchedstatements=true sonar.jdbc.driverClassName= Com.mysql.jdbc.Driver

The new Sonarqbude table has new changes to the old version, and it needs to be removed from the old table. Otherwise you will report the following error.     JS code exception caught on transport layer [[id:0xc7fbf08e,/127.0.0.1:55381 =>/127.0.0.1:9001]], closing connection Java.io.IOException: The remote host forced the shutdown of an existing connection.

4.2 Start Sonarqube



Run "Startsonar.bat" to access Port 9000, sonar default to bring the jetty server.

Default User name password admin, admin. Some settings and menus can only be seen after landing.

The port is changed to 9090 because the personal 9000 port has other uses. Java Code sonar.web.port=9090

4.3 Sonarqube of Chinese

Official website Address Http://docs.sonarqube.org/display/PLUG/Plugin+Library


Place the Sonar-l10n-zh-plugin-1.13.jar under the Sonarqube-6.2\extensions\plugins. Restart Sonarqube. Soanrqube has some plug-ins that need to be used for code analysis. Introduction to Plug-ins

The download address for the plugin is: http://docs.codehaus.org/display/SONAR/Plugin+Library

Upload the downloaded plugin to the ${sonar_home}extensions\plugins directory and restart the SONAR.

Sonar the default integration of the Java Ecosystem Plug-in, the plug-in is a collection of a set of Plug-ins

(1) Java [Sonar-java-plugin]:java Source code Analysis, calculation indicators, etc.

(2) Squid [Sonar-squid-java-plugin]: Check code that violates sonar definition rules

(3) Checkstyle [Sonar-checkstyle-plugin]: Use Checkstyle to check code that violates the coding style of the unified code

(4) FindBugs [Sonar-findbugs-plugin]: Use FindBugs to check for defect codes that violate rules

(5) PMD [Sonar-pmd-plugin]: Use PMD to check code that violates rules

(6) Surefire [Sonar-surefire-plugin]: Performing unit tests using surefire

(7) Cobertura [Sonar-cobertura-plugin]: Obtaining code Coverage using Cobertura

(8) Jacoco [Sonar-jacoco-plugin]: Obtaining code Coverage using Jacoco

Common plug-ins:

(1) JavaScript code check: Http://docs.codehaus.org/display/SONAR/JavaScript+Plugin

(2) Python code check: Http://docs.codehaus.org/display/SONAR/Python+Plugin

(3) Web page check (HTML, JSP, JSF, Ruby, PHP, etc.): Http://docs.codehaus.org/display/SONAR/Web+Plugin

(4) XML file check: Http://docs.codehaus.org/display/SONAR/XML+Plugin

(5) SCM source database statistical analysis: Http://docs.codehaus.org/display/SONAR/SCM+Stats+Plugin

(6) File metrics: Http://docs.codehaus.org/display/SONAR/Tab+Metrics+Plugin

(7) Chinese Language pack: Http://docs.codehaus.org/display/SONAR/Chinese+Pack

(8) Timesheet Display measurement results: http://docs.codehaus.org/display/SONAR/Timeline+Plugin

(9) Measurement results Evolution diagram: Http://docs.codehaus.org/display/SONAR/Motion+Chart+Plugin

(b) Example plug-in configuration (this section is from http://www.ibm.com/developerworks/cn/java/j-lo-sonar/

Five Sonar-runner installation

5.1 Modify the Sonar-scanner.properties profile of Conf under Sonar-runnerc

Java code sonar.host.url=http://localhost:9090 sonar.jdbc.username=root sonar.jdbc.password=11111 SONAR.JDBC.URL=JDBC    : Mysql://10.10.5.64:3306/sonar?useunicode=true&characterencoding=utf8&rewritebatchedstatements=true Sonar.jdbc.driverclassname=com.mysql.jdbc.driver

5.2 Add files to the root of the project Sonar-project.properties

1 Single project Java code SONAR.PROJECTKEY=PLJJ SONAR.PROJECTNAME=PLJJ sonar.projectversion=1.0-snapshot sonar.sources=src/ma In/java Sonar.tests=src/test/java sonar.binaries=target/classes Sonar.language=java

2 Maven multi-module Java code SONAR.PROJECTKEY=PLJJ SONAR.PROJECTNAME=PLJJ sonar.projectversion=1.0 sonar.sources=. Sonar.language=java Sonar.sourceencoding=utf-8

or Java code sonar.projectkey=com.pljj-job sonar.projectname=elastic-job sonar.projectversion=1.1.0 # Set Modules IDs Sonar.modules=pljj-core,pljj-console,pljj-spring # modules inherit properties set at parent level SONAR.SOURCES=SRC /main/java Sonar.tests=src/test/java Sonar.java.binaries=target Sonar.language=java

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.