PHP Dev程序员Jenkins

jenkins & php的持续集成测试环境配置

2016-12-27  本文已影响869人  zigo

之前写了jenkins的安装和安全配置,今天这篇文章主要是关于php的持续集成测试环境的配置。

安装jenkins插件

2C9CBEA6-28F8-4855-A5D7-3A3DD86725C3.png 0BED92E6-ECA1-4C82-9329-D832C435CDE8.png A86A339F-C060-4506-BE6C-268073EF4A1F.png
export JCLIUSER=admin
# 获取jenkins的初始密码
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
export JCLIPASS=<YOUR PASSWORD>

安装插件的命令

wget http://localhost:8080/jnlpJars/jenkins-cli.jar
java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin \ 
      checkstyle cloverphp crap4j dry htmlpublisher jdepend \ plot pmd           
      violations warnings xunit git greenballs \ 
      --username $JCLIUSER --password $JCLIPASS
java -jar jenkins-cli.jar -s http://localhost:8080 safe-restart --username $JCLIUSER --password $JCLIPASS

安装php, composer, tools

sudo LC_ALL=en_US.UTF-8 add-apt-repository -y ppa:ondrej/php
sudo apt-get updatesudo apt-get install -y php7.0 php7.0-xdebug \
     php7.0-xsl php7.0-dom php7.0-zip php7.0-mbstring
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composerphp -r "unlink('composer-setup.php');"
sudo chown -R $USER:$USER ~/.composer/
composer global config minimum-stability dev
composer global config prefer-stable true
composer global require phpunit/phpunit squizlabs/php_codesniffer \ 
phploc/phploc pdepend/pdepend phpmd/phpmd sebastian/phpcpd \
mayflower/php-codebrowser theseer/phpdox:dev-master
curl -L https://raw.githubusercontent.com/modess/php-jenkins-template/master/config.xml | \ 
java -jar jenkins-cli.jar -s http://localhost:8080 create-job php-template --username $JCLIUSER --password $JCLIPASS
612F4A85-BF85-42C6-9AAD-E80946794F7D.png

集成项目

新建一个job

062F62EF-C791-4309-A8D4-AED1B2D23A1A.png

代码源配置,我们使用github上面的Money项目

6B3B3D4C-1B33-4DDA-B83E-7172237BF8E3.png

添加Money项目的github地址,然后在Credentials哪里点击带钥匙图标的Add按钮,添加github的账号和密码,点击上图左边菜单栏中的【立即构建】

B7780621-78A9-4807-8FFB-EF438EC2B524.png

ok, 这样子使用jenkins来对php项目进行持续集成测试的环境就搭建好了,执行成功是蓝色的小球,执行失败是红色的小球,最后上几张图执行测试成功的图

331E3A49-B19C-4C48-B572-A31916603EEA.png 47A2870E-FB92-4E87-B610-B1F6456CBFF5.png 5D14704C-0974-48EF-9B6D-5503C2B64FC7.png C3E65ED2-8391-46FD-A7A7-AC914DD4EF54.png 39BF754F-BEF3-4DFC-A70E-945EE6E5717D.png 6196A9D1-229D-4B7D-820E-433436CDD5FC.png

![Uploading 103AF0C9-0F6A-4D53-B4E6-45D93856AC70_563952.png . . .]

上一篇下一篇

猜你喜欢

热点阅读