我在jenkins中使用build.xml时遇到问题。 当我执行phpmd,phpcs phpcpd,phpdoc,pdepend,phploc时,我必须排除一些目录... 对于上面这些中的每一个,我的--exclude或--ignore params都不起作用....而且我对jenkins的构建是如此之长。 我必须忽略一些文件夹,如(vendor(zend框架),js(用于Jquery和jquery插件),以及其他一些像测试(用于PHPunit)) 这是我的XML:
当我创建这个XML时,我在Google上查看了一些帮助,我发现了这个:
答案 0 :(得分:3)
以下是经过大量脑震后的解决方案:
<?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 call。
This Phing build.xml was so usefull for this problem !!
希望这能帮助某人,并说服其他人在Zend Framework项目中与Jenkins合作进行持续集成!