这是很多头痛后的解决方案:
<?xml version="1.0" encoding="UTF-8"?>
<fileset id="php-files" dir="${basedir}">
<include name="**/*.php"/>
<exclude name="vendor/**"/>
<exclude name="build/**"/>
<exclude name="tests/**"/>
</fileset>
<target name="main" description="Start analyzing our application">
<echo msg="Start Build" />
<phingCall target="clean" />
<phingCall target="prepare" />
<phingCall target="phpunit" />
<phingCall target="pdepend" />
<phingCall target="phpmd-ci" />
<phingCall target="phpcpd" />
<phingCall target="phpdoc" />
<phingCall target="phpcs-ci" />
<phingCall target="phploc" />
<phingCall target="phpcb" />
<echo msg="Finished Build" />
</target>
<target name="clean" description="Delete old stuff">
<delete dir="${basedir}/build/api"/>
<delete dir="${basedir}/build/coverage"/>
<delete dir="${basedir}/build/code-browser"/>
<delete dir="${basedir}/build/logs"/>
<delete dir="${basedir}/build/pdepend"/>
</target>
<target name="prepare" depends="clean" description="prepare new build">
<mkdir dir="${basedir}/build/api"/>
<mkdir dir="${basedir}/build/coverage"/>
<mkdir dir="${basedir}/build/code-browser"/>
<mkdir dir="${basedir}/build/logs"/>
<mkdir dir="${basedir}/build/pdepend"/>
</target>
<!-- works perfectly -->
<target name="phploc" description="your project is too heavy loose weight fat boy">
<exec executable="phploc.bat">
<arg path="${basedir}/module" />
<arg value="--log-csv" />
<arg value="${basedir}/build/logs/phploc.csv" />
</exec>
</target>
<!-- works perfectly -->
<target name="pdepend" description="more metrics chart please">
<exec command="pdepend --jdepend-xml=${basedir}/build/logs/jdepend.xml
--jdepend-chart=${basedir}/build/pdepend/dependencies.svg
--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg
--suffix=php
--ignore=vendor,tests,build,public/js
${basedir}"
escape="false" />
</target>
<!-- works perfectly -->
<target name="phpmd-ci" description="Generate pmd.xml using PHPMD">
<phpmd rulesets="codesize,design,naming,unusedcode">
<fileset refid="php-files"/>
<formatter type="xml" outfile="${basedir}/build/logs/pmd.xml"/>
</phpmd>
</target>
<!-- works perfectly -->
<target name="phpcs-ci" description="coding with checkstyle">
<exec passthru="false" command="phpcs
--report=checkstyle
--report-file=${basedir}/build/logs/checkstyle.xml
--standard=Zend
--ignore=vendor,tests,public/js,build
--extensions=php
${basedir}"/>
</target>
<!-- Ne marche pas non plus en raison de : pas de test unitaire encore -->
<target name="phpcpd" description="repeat yourself is killing you">
<exec executable="phpcpd">
<arg line="--log-pmd ${basedir}/build/logs/pmd-cpd.xml
--exclude ${basedir}/vendor
--exclude ${basedir}/tests
--exclude ${basedir}/build
--exclude ${basedir}/js
--suffixes php
${basedir}" />
</exec>
</target>
<target name="phpdoc" description="Generate API documentation using PHPDocumentor">
<phpdoc title="MyLink API Documentation"
destdir="${basedir}/build/api"
sourcecode="false"
output="HTML:Smarty:PHP"
quiet="true">
<fileset refid="php-files"/>
</phpdoc>
</target>
<target name="phpunit" description="test your code">
<exec command="phpunit.bat
--bootstrap=${basedir}/tests/Bootstrap.php
--configuration=${basedir}/tests/phpunit.xml
--log-junit ${basedir}/build/logs/junit.xml
--coverage-clover ${basedir}/build/logs/clover.xml
--coverage-html ${basedir}/build/coverage/"/>
</target>
<!-- works perfectly -->
<target name="phpcb" description="are you coding properly">
<exec executable="phpcb.bat">
<arg value="--log" />
<arg path="${basedir}/build/logs" />
<arg value="--source" />
<arg path="${basedir}" />
<arg value="--output" />
<arg path="${basedir}/build/code-browser" />
<arg value="--ignore"/>
<arg path="${basedir}/vendor/,${basedir}/tests/,${basedir}/build/,${basedir}/public/js/"/>
</exec>
</target>
解决方案是进行一些语法调整,并使用 phing 语法,尤其是 phings 调用。
这个 Phing build.xml 对这个问题非常有用!
希望这对某人有所帮助,并说服其他人在 Zend Framework 项目中与 Jenkins 一起工作以进行持续集成!