系统:debian8.6
环境:lnmp(参考:lhttps://blog.linuxeye.cn/31.html)
jenkins: jenkins 2.7.2
sonarQube:sonarQube5.6
sonarscanner:Sonarscanner3.0.3
java:jdk8
2:java的安装配置
我已经吧环境需求文件放到了我的'百度网盘'链接:http://pan.baidu.com/s/1mi40gNe 密码:vrp2
下载到本地计算机
上传到服务器上面: 通过winscp或者lrzsz上传到服务都可以,根据自己的方式
我此处:放到了/data/soft下面通过lrzsz方式
root@iZ2zeb1kcfbotalsu02k64Z:/data/soft# apt-get install lrzsz
root@iZ2zeb1kcfbotalsu02k64Z:/data/soft# rz
选择自己刚刚下载的文件上传到此目录即可
java环境配置
root@iZ2zeb1kcfbotalsu02k64Z:/data/soft#tar xf jdk8.tar.gz
root@iZ2zeb1kcfbotalsu02k64Z:/data/soft# vim /etc/profile
export PATH=/usr/local/nginx/sbin:/usr/local/php/bin:/usr/local/mysql/bin:/usr/local/node/bin:/data/soft/jdk8/bin:$PATH
root@iZ2zeb1kcfbotalsu02k64Z:/data/soft# source /etc/profile
检测java环境是否安装完毕
root@iZ2zeb1kcfbotalsu02k64Z:/data/soft# java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mod
3:jenkins安装配置
参考:http://pkg.jenkins-ci.org/
找到属于自己服务环境的点击进去,按照步骤安装即可
4:sonarqube安装配置
配置mysql:
MySQL [(none)]> create database sonar character set utf8 collate utf8_general_ci;
MySQL [(none)]>grant all on sonar.* to 'ops'@'localhost' identified by 'ops12300.';
MySQL [(none)]>flush privileges;
解压sonarqube到/usr/localMySQL [(none)]>flush privileges;
root@iZ2zeb1kcfbotalsu02k64Z:/data/soft# unzip sonarqube-5.6.6.zip -d /usr/local/
配置sonarqube
root@iZ2zeb1kcfbotalsu02k64Z:/usr/local/sonarqube-5.6.6/conf# cd /usr/local/sonarqube-5.6.6/conf/
root@iZ2zeb1kcfbotalsu02k64Z:/usr/local/sonarqube-5.6.6/conf# vim sonar.properties
root@iZ2zeb1kcfbotalsu02k64Z:/usr/local/sonarqube-5.6.6/conf# cat sonar.properties|grep -v "^#"
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
sonar.jdbc.username=ops
sonar.jdbc.password=ops12300.
sonar.sourceEncoding=UTF-8
sonar.login=admin
sonar.projectKey=fangxin:11
sonar.projectName=fangxin
sonar.projectVersion=1.0
sonar.password=admin@1fangxin
启动sonarQube
root@iZ2zeb1kcfbotalsu02k64Z:/usr/local/sonarqube-5.6.6#
root@iZ2zeb1kcfbotalsu02k64Z:/usr/local/sonarqube-5.6.6# ./bin/linux-x86-64/sonar.sh start
日志:logs/sonr.log
访问日志:logs/access.log
5:jenkins设置安装sonarQube插件root@iZ2zeb1kcfbotalsu02k64Z:/usr/local/sonarqube-5.6.6#
root@iZ2zeb1kcfbotalsu02k64Z:/usr/local/sonarqube-5.6.6# ./bin/linux-x86-64/sonar.sh start
日志:logs/sonr.log
访问日志:logs/access.log
系统管理->插件管理->可选插件->sonarqube plugin 点击安装
5.2:安装配置
JenkinsGlobal Tool Configuration
配置sonarqube的网址和token:
系统管理->系统设置->
token获取
此处的token填入上面的token即可
6:sonarQube安装破解包和php环境
此处的php和chine语言都是以插件的形式安装的
在search里面搜索sonarphp和chine点击insall,之后在重启sonarQube服务即可
7:配置程序sonarscnner
root@iZ2zeb1kcfbotalsu02k64Z:/usr/local/sonarqube-5.6.6# cd /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation
root@iZ2zeb1kcfbotalsu02k64Z:/var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation# ls
Sonarqube_scan2.6 Sonarqube_scan3.0.3 sonarsc3.03
root@iZ2zeb1kcfbotalsu02k64Z:/var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation# vim Sonarqube_scan3.0.3/conf/sonar-
sonar-runner.properties sonar-scanner.properties sonar-scanner.properties.back
root@iZ2zeb1kcfbotalsu02k64Z:/var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation# vim Sonarqube_scan3.0.3/conf/sonar-runner.propertiesroot@iZ2zeb1kcfbotalsu02k64Z:/var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation# cat Sonarqube_scan3.0.3/conf/sonar-runner.properties
#Configure here general information about the environment, such as SonarQube DB details for example
#No information about specific project should appear here
#----- Default SonarQube server
#sonar.host.url=http://localhost:9000
sonar.host.url=http://192.168.1.10:9000
#----- PostgreSQL
#sonar.jdbc.url=jdbc:postgresql://localhost/sonar
#----- MySQL
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
#----- Oracle
#sonar.jdbc.url=jdbc:oracle:thin:@localhost/XE
#----- Microsoft SQLServer
#sonar.jdbc.url=jdbc:jtds:sqlserver://localhost/sonar;SelectMethod=Cursor
#----- Global database settings
#sonar.jdbc.username=sonar
sonar.jdbc.username=ops
sonar.jdbc.password=ops12300.
#sonar.jdbc.password=sonar
#----- Default source code encoding
sonar.sourceEncoding=UTF-8
#----- Security (when 'sonar.forceAuthentication' is set to 'true')
#sonar.login=admin
#sonar.password=admin
sonar.sourceEncoding=UTF-8
sonar.projectKey=fangxin:11
sonar.projectName=fangxin
sonar.projectVersion=1.0
sonar.sources=.
sonar.language=php
root@iZ2zeb1kcfbotalsu02k64Z:/var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/Sonarqube_scan3.0.3# cat conf/sonar-scanner.properties
#Configure here general information about the environment, such as SonarQube DB details for example
#No information about specific project should appear here
#----- Default SonarQube server
#sonar.host.url=http://localhost:9000
#----- Default source code encoding
#sonar.sourceEncoding=UTF-8
#----- Global database settings (not used for SonarQube 5.2+)
#sonar.jdbc.username=sonar
#sonar.jdbc.password=sonar
#----- PostgreSQL
#sonar.jdbc.url=jdbc:postgresql://localhost/sonar
#----- MySQL
#sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
#----- Oracle
#sonar.jdbc.url=jdbc:oracle:thin:@localhost/XE
#----- Microsoft SQLServer
#sonar.jdbc.url=jdbc:jtds:sqlserver://localhost/sonar;SelectMethod=Cursor
sonar.sources=/home/qa/erp
sonar.projectKey=fangxin:11
sonar.projectName=fangxin
sonar.projectVersion=1.0
sonar.language=php
8:代码提交检查
提交检查