SonarQube + Jenkins Code Review Environmental installation documentation v1.2

 

1.  Installation SonarQube

1.1.  Download

Download: https: //www.sonarqube.org/downloads/

The installation package is used: sonarqube-7.4.zip

You need to prepare in advance jdk1.8, mysql-5.6.

1.2.  Installation

1 , extract the installation package

2 , prepare the database ( MySQL )

A ) New Database User Database and

Building a database SQL ( SONAR / SONAR )

CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE USER 'sonar' IDENTIFIED BY 'sonar';

GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';

GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';

FLUSH PRIVILEGES;

B ) modify the configuration file database the conf / sonar.properties :

sonar.jdbc.username=sonar

sonar.jdbc.password=sonar

sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding    =utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false

 

1.3.  Start

New sonar users;

Start mysql database;

Then execute the following command:

its sound

cd /data/sonarqube-7.4/bin/linux-x86-64

./sonar.sh start

Be careful not to use root starts. sonarqube comes es , all can not use root privileges.

 

1.4.  Access

Default access address: http://10.15.1.28:9000

admin / admin

2.  Installation Configuration Jenkins

2.1.  Jenkins installation

slightly

2.2.  Installation gradle

Download Unzip the package, configure the environment variables

export GRADLE_HOME=/data/gradle-2.8

export PATH=$GRADLE_HOME/bin:$PATH

The use 2.8 version project needs.

2.3.  Installation Jenkins plugin

  1. SonarQube Scanner for Jenkins
  2. Folders Plugin
  3. Git client plugin
  4. Git plugin
  5. Python Plugin

2.4.  Tool Configuration

. 1 , S onarQube Scanner Configuration:

 

 

 

 

3.  Jenkins Task Configuration

3.1.  The Java task configuration

 

 

 

 

 

 

 

 

clean build -x test

 

 

 

 

sonar.projectKey=$JOB_BASE_NAME

sonar.projectName=$JOB_BASE_NAME

sonar.projectVersion=1.0.0

sonar.language=java

sonar.java.source=1.8

#sonar.sources=src

sonar.sources=${WORKSPACE}/src/main/java

sonar.sourceEncoding=UTF-8

sonar.java.binaries=${WORKSPACE}/build/

 

 

 

 

Report View Address :

<a href="http://10.15.1.28:9000/dashboard?id=$JOB_BASE_NAME">http://10.15.1.28:9000/dashboard?id=$JOB_BASE_NAME</a><br>

(本邮件由系统自动发出)

 

 

3.2. python任务

只列出与java任务不同之处:

 

 

 

sonar.projectKey=$JOB_BASE_NAME

sonar.projectName=$JOB_BASE_NAME

sonar.projectVersion=1.0.0

sonar.sources=.

sonar.sourceEncoding=UTF-8

 

4. 附录

4.1. elasticsearch启动错误

1、max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

 

每个进程最大同时打开文件数太小,可通过下面2个命令查看当前数量

ulimit -Hn

ulimit -Sn

 

修改/etc/security/limits.conf文件,添加如下配置:

sonar    hard    nofile       65536

sonar    soft    nofile       65536

root    hard    nofile       65536

root    soft    nofile       65536

重新登陆即生效。

临时修改命令如下:(重启后失效)

ulimit -n 65535

 

 

2、max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

 

修改/etc/sysctl.conf文件,添加配置

vm.max_map_count=262144

 

执行命令sysctl -p生效

 

Guess you like

Origin www.cnblogs.com/gongxr/p/11597044.html