Jenkins+gitlab+sonar Code inspection platform to build-sonar__sonar

Source: Internet
Author: User
Tags chmod flush mysql version
Sonar Platform Setup Install sonar Environment
add environment variables
export path= "/LETV/REDIS-2.8.17/SRC: $SONAR _home: $SONAR _runner_home/bin: $MAVEN _home/bin: $PATH"
Export sonar_home=/usr/local/src/sonarqube-5.6.4/bin/linux-x86-64
Export sonar_runner_home=/usr/local/src/ SONAR-SCANNER-2.6.1/
Export maven_home=/usr/local/src/apache-maven-3.3.9

Install the database and configure >sonar also need to install MySQL database (more than 5.6)
This group DBA has been installed to see if it fits well

Install this yourself. This is 5.6, the group database version is not supported.
# RPM-IVH mysql-community-release-el6-7.noarch.rpm
#yum Install mysql-server-y
#/etc/init.d/mysqld start

GRANT all on sonar.* to ' sonar ' @ ' localhost ' identified by ' SONAR@PW ';
GRANT all on sonar.* to ' sonar ' @ '% ' identified by ' SONAR@PW ';
FLUSH privileges;
Take care of
sonar.jdbc.url=jdbc:mysql://localhost. : 3306/sonar?useunicode=true&characterencoding=utf8&rewritebatchedstatements=true&useconfigs= Maxperformance

Before testing the environment for some pits

1, mysql5.7 need to use complex passwords (not recommended), and modify the password method as follows
first modify VIM/ETC/MY.CNF
and then try the
update Mysql.user Set Authentication_string=password (' Keynzh0ok5puioix ') where user= ' root ';
ALTER USER ' root ' @ ' localhost ' identified by ' Dwlrdko4ateo^wzh ';
Then cancel #skip-grant-tables restart
mysqld, and then create the sonar library before you can.
2, modify the JDBC Connection pool
Sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useunicode=true &characterencoding=utf8&rewritebatchedstatements=true&useconfigs=maxperformance
3, JDK version must be more than 1.8 or throw abnormal

Come here to test the group MySQL

Mysql-h sonar_w-p *******

Modify the configuration file as follows
sonar.jdbc.url=jdbc:mysql:// Useconfigs=maxperformance

Start sonar

Source/etc/profile Start

Check the log to find the linked database error

2017.01.23 17:58:21 ERROR web[o.a.c.c.c.[.[. [/]] Exception sending context initialized event to listener instance of class Org.sonar.server.platform.PlatformServletContextListener
org.sonar.api.utils.MessageException:Unsupported MySQL version:5.5. Minimal supported version is 5.6.

To view the MySQL version, does not meet the 5.6 requirements

mysql> status
mysql  Ver 14.14 distrib 5.1.73, for Redhat-linux-gnu (x86_64) using ReadLine 5.1

Connection ID:      354 current
database: Current   
User:       sonar_w@
SSL: Not in use
Current Pager:      stdout
using outfile:      '
using delimiter:    ;
Server version:     5.5.5-10.0.14-mariadb-log Source distribution
Protocol version:
Connection: via TCP/IP
Server characterset:    UTF8
Db     characterset:    UTF8
Client characterset:    UTF8
Conn.  CharacterSet:    UTF8
TCP port:       3927
Uptime:         7 hours min sec

threads:2  questions:5224  Slow queries:0  opens:0  Flush tables:1  Open tables:63  queries per second avg: 0.195

IE input if you can access this process is about 10 minutes, the default username and password are admin, the installation is over I have to create a new user to give admin permissions, Once was a teammate Pit Admin permissions have been deleted. The English interface is not very friendly, the following he han.

/usr/local/src/sonarqube-5.6.4/bin/linux-x86-64/ restart

I just wrote a startup script to share.

RC file for sonarqube  
chkconfig:345 #  
Description:sonarqube System (Www.sona  
# provides:sonar  
# Required-start: $network  
# Required-stop: $ Network  
# Default-start:3 4 5  
# default-stop:0 1 2 6  
# Short-description:sonarqube System (Www.sonarsour  
# Description:sonarqube System (  
### end INIT INFO  

#/usr/bin/sonar $*
/usr/local/src/sonarqube-5.6.4/bin/linux-x86-64/ $*

service sonar restart no problem.

power-on Boot

Sonarqube Boot from (Ubuntu, 32-bit):
sudo ln-s $SONAR _home/bin/linux-x86-32/
sudo chmod 755/ Etc/init.d/sonar
sudo update-rc.d sonar defaults
sonarqube boot from (RedHat, CentOS, 64-bit):
#sudo ln-s $SONAR _ Home/bin/linux-x86-64/
sudo ln-s $SONAR _home/
sudo chmod 755/ Etc/init.d/sonar
sudo chkconfig--add sonar

Installing the Sonar Plugin

Install scanner plugin > Note This scanner is to be installed on the Jenkins server

# cd/usr/local/src/
# wget 
# Unzip
#ln-S/usr/local/sonar-scanner-2.6.1 //usr/local/sonar-scanner
configuration Let the scanner be associated with Sonar
# CD 
# cd/usr/local/sonar-scanner/conf/
# grep ' ^[a-z '
sonar.jdbc.url=jdbc:mysql:// Sonar?useunicode=true&characterencoding=utf8

Download the test code to test

# CD
# wget Https:// #
# CD/ Root/sonar-examples-master/projects/languages/php/php-sonar-runner
#/usr/local/sonar-scanner/bin/ Sonar-scanner


[root@gitlab-102 php]# pwd
[root@gitlab-102 php]# Cat Php-sonar-runner/ 
# Required metadata
Sonar.projectkey=org.sonarqube: Php-simple-sq-scanner
sonar.projectname=php:: Simple Project:: Sonarqube scanner

# comma-separated paths to directories with sources (required)

# Language
sonar.language=php #
# Encoding of the source files

Sonar's token

Configure Sonar

Configure Sonar Scanner

Jenkins directly pull up my previous upload Gitlab code

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: 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.