Configuring sonarqube_jenkins for continuous Java Code Auto-build Review

Source: Internet
Author: User
Tags continuous integration tools

This article takes the CentOS operating system as an example to introduce the installation configuration of Sonarqube and how to integrate with Jenkins
 ServerEnvironment:
[Email protected] data]# uname-a
Linux Db-server 3.10.0-327.36.3.el7.x86_64
[Email protected] data]# java-version
OPENJDK Version "1.8.0_111"
[Email protected] data]# nginx-v
Nginx version:nginx/1.10.2
[Email protected] data]# mysql-v
MySQL Ver 15.1 distrib 5.5.50-mariadb
Sonarqube-5.3.zip

I. Installing the configuration sonar and configuration database

1, Sonar introduction

sonar is an open source platform for code Quality management that manages the quality of Java source code. Through the plug-in mechanism, Sonar can integrate different test tools, code analysis tools, and continuous integration tools such as PMD-CPD, Checkstyle, FindBugs, Jenkins. These results are re-processed by different plug-ins and quantified to measure the change in code quality, which makes it easy to code quality management for projects of different sizes and types.

Sonar also provides interface support for a large number of continuous integration tools, which makes it easy to use sonar in continuous integration.

In addition, Sonar's plug-in provides support for programming languages other than Java, as well as internationalization and reporting documentation.
Can download the latest Sonarqube package, but this time I am installing the version of the Sonarqube 5.3
https://www.sonarqube.org/downloads/
Find the corresponding version of the download can, I have downloaded here to upload to my Baidu cloud disk inside the Http://pan.baidu.com/s/1c2aOor2
Download to local, upload to server via Lrzsz

Sonar.properties I configure the Sonarqube configuration file here, can be appropriately modified to conform to their own files
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useunicode=true&characterencoding=utf8& Rewritebatchedstatements=true&useconfigs=maxperformance #链接的数据库
sonar.jdbc.username=root #用户
sonar.jdbc.password=root12300. #密码
Sonar.sorceencoding=utf-8 #字符集
sonar.login=admin #登录账号
#sonar. Projectkey=hanye:11 #key
#sonar. Projectname=hanye #显示的名字
sonar.projectversion=1.0 #项目版本
Sonar.password=admiN#登录密码
Configuration database
Mysql> CREATE DATABASE sonar CHARACTER SET UTF8 COLLATE utf8_general_ci;
mysql> CREATE USER ' sonar ' identified by ' sonar ';
Mysql> GRANT all on sonar.* to ' sonar ' @ '% ' of ' identified by ' sonar ';
Mysql> GRANT all on sonar.* to ' sonar ' @ ' localhost ' identified by ' sonar ';
mysql> FLUSH privileges;
Start Sonarqube
I've installed it in the data directory.
[Email protected] sonarqube-5.3]# cd/data/sonarqube-5.3
Configuration file: Conf
Log location: Bin
Startup script Location: Log
[Email protected] sonarqube-5.3]#/bin/linux-x86-64/sonar.sh restart

Here Sonarqube will occupy 9000 and 9001 ports, you need to modify the configuration file modification port can be modified, after modification, Jenkins on the link sonar port also to be modified
Log in to view


Second, installation configuration jenkins,maven,jdk
Refer to my blog: http://www.ny01.top/?p=126
Configuring the JDK and maven to install Jenkins
System Management-Global Tool CONFIGURATION->JDK
 
System Management-Global Tool Configuration->maven


Third, Jenkins configuration Sonarqube plug-ins and installation Sonarqube scanner
Installing the Sonarqube plugin plugin
System Management - plug-in management, optional plug-in->sonarqube plugin click to install
 
installing Sonarqube Scanner  
System Management -> configuration link SonarQube
  System Management-system settings-SonarQube servers
     

Log on to Sonarqube Web side, find Administrator
login-administrator-"security-" User


Start creating a project test
Create a maven project named Test_scan_sonar
I put the code on SVN above

Other default can
find pre Steps
  


Other keep default
after creation   Click   Build now


then wait for download dependent environment, and auto build can   time may be longer
if you encounter

sonarqube scanner exited with non-zero code: 1 

problem, basically is sonarqube SCM forgot to open, so log on to Sonarqube Web side open SCM
administrator-"configureation-" General settings-"SCM
itDisable the SCM Sensor is set to True, click Save SCM settings to build again to see the effect
 
Once the build is complete, you can log in to Jenkins and Sonarqube to see if the code is in trouble.

Click OK on hz7726 to jump to the Web port of the connection Sonarqube you just set up to view it

after login found hz7726 has come out, the others are looking for development to modify this code
 
for reference only, big God do not spray, if have the question can mail [email protected] contact, or qq:1263567419 I can't help you anyway
Note: If you have more items, you can modify
inside the Projectkey and projectname to identify different projects.


Configuring sonarqube_jenkins for continuous Java Code Auto-build Review

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.