持续构建jenkins+sonar5.6自动审查php环境
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了持续构建jenkins+sonar5.6自动审查php环境相关的知识,希望对你有一定的参考价值。
1:需求文件整理
系统: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方式
[email protected]:/data/soft# apt-get install lrzsz
[email protected]:/data/soft# rz
选择自己刚刚下载的文件上传到此目录即可
java环境配置
[email protected]:/data/soft#tar xf jdk8.tar.gz
配置环境变量
[email protected]:/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
[email protected]:/data/soft# source /etc/profile
检测java环境是否安装完毕
[email protected]:/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/local
[email protected]:/data/soft# unzip sonarqube-5.6.6.zip -d /usr/local/
配置sonarqube
[email protected]:/usr/local/sonarqube-5.6.6/conf# cd /usr/local/sonarqube-5.6.6/conf/
[email protected]:/usr/local/sonarqube-5.6.6/conf# vim sonar.properties
[email protected]:/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
[email protected]
启动sonarQube
[email protected]:/usr/local/sonarqube-5.6.6#
[email protected]:/usr/local/sonarqube-5.6.6# ./bin/linux-x86-64/sonar.sh start
日志:logs/sonr.log
访问日志:logs/access.log
5:jenkins设置安装sonarQube插件
系统管理->插件管理->可选插件->sonarqube plugin 点击安装
5.2:安装配置
JenkinsGlobal Tool Configuration
配置sonarqube的网址和token:
系统管理->系统设置->
token获取
此处的token填入上面的token即可
6:sonarQube安装破解包和php环境
此处的php和chine语言都是以插件的形式安装的
在search里面搜索sonarphp和chine点击insall,之后在重启sonarQube服务即可
7:配置程序sonarscnner
[email protected]zeb1kcfbotalsu02k64Z:/usr/local/sonarqube-5.6.6# cd /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation
[email protected]:/var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation# ls
Sonarqube_scan2.6 Sonarqube_scan3.0.3 sonarsc3.03
[email protected]:/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
[email protected]:/var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation# vim Sonarqube_scan3.0.3/conf/[email protected]:/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
[email protected]:/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:代码提交检查
提交检查
以上是关于持续构建jenkins+sonar5.6自动审查php环境的主要内容,如果未能解决你的问题,请参考以下文章
配置sonarqube_jenkins进行持续JAVA代码自动构建审查
Jenkins——Jenkins项目构建细节(触发构建和)和SonarQube代码审查