第一步 Git 得到待檢測(cè)php文件
version=git log --pretty=format:"%H" -1 --author=yidao
author=git log --pretty=format:"%an" -1
email=git log --pretty=format:"%ae" -1
files=git diff-tree --no-commit-id --name-only -r $version | grep "Lib*" |sed -e 's/\s/,/g'
files=echo $files|sed -e 's/\s/,/g'
2 Phpmd
phpmd $files html codesize,unusedcode --reportfile build/logs/$version.html
3 Phpunit
phpunit --testsuite all
phpunit.xml基礎(chǔ)配置之外加上
4 Mail 發(fā)郵件給開(kāi)發(fā)者
郵件內(nèi)容寫(xiě)入build/logs/mail
mail -s "PHPMD && PHPUNIT report" $email < build/logs/mail