Ubuntu jenkins + git + phpunit

安装 jenkins
wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -  
sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'  
sudo apt-get update  
sudo apt-get install jenkins  

 关闭和启动

sudo /etc/init.d/jenkins start  
sudo /etc/init.d/jenkins stop  

启动之后可以访问8080端口去访问jenkins主页,当然也可以用nginx 或者apache做个代理去实现url访问。


git plugin 安装

 系统管理->管理插件->可选插件  然后搜索git plugin, 然后立即安装

如果遇到安装进度卡顿,我卡了一天一夜也没完成安装,可以先重启jenkins,必要的时候可以多重启几次。

然后创建任务,在源码管理里面选择git,输入git仓库地址。但 此时服务器上的git一定要生成ssh key并添加到用户上(linux下一定要用jenkins合格用户去操作生成),否则会提示没有权限访问git仓库。


PHPunit 

安装方法官网上已经很详细,在此不做过多介绍

在windows下可以通过composer安装,基本上不会出现太大问题。在ubuntu系统下通过apt-get安装会提示

PHP Warning:  require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 39
PHP Fatal error:  require_once(): Failed opening required 'PHP/CodeCoverage/Filter.php' (include_path='.:/usr/share/php:/usr/share/pear') in /usr/bin/phpunit on line 39

可以通过更新库来解决这个问题

sudo apt-get remove phpunit
sudo pear upgrade pear
sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover pear.symfony-project.com
sudo pear channel-discover components.ez.no
sudo pear update-channels
sudo pear upgrade-all
sudo pear install --alldeps phpunit/PHPUnit 
sudo pear install --force --alldeps phpunit/PHPUnit

安装Selenium和 DbUnit等扩展

pear install phpunit/PHPUnit_Selenium
pear install phpunit/DbUnit
pear install phpunit/PHPUnit_Story

在安装DbUnit的时候可能提示

Unknown remote channel: pear.symfony.com
phpunit/DbUnit requires package "channel://pear.symfony.com/Yaml" (version >= 2.1.0)

解决方法

pear channel-discover pear.symfony.com
pear install pear.symfony.com/Yaml


在命令行输入

phpunit --log-junit /var/www/rr.xml MainTest.php

即可看到结果了



最后添加构建完成后的操作,执行测试脚本即可

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值