我已经在Linux环境中安装了Jenkins。我有一台充当从机的SunOs服务器,该服务器上有phpunit.phar二进制文件。在服务器中,我可以执行phpunit。我创建了一个Jenkins作业,该作业将在从机上运行,该从机将使用ANt构建执行phpunit。
build.xml:
<project name="name-of-project" default="full-build">
<!-- By default, we assume all tools to be on the $PATH -->
<property name="phpunit" value="phpunit"/>
<!--
<property name="phpunit" value="${basedir}/build/tools/phpunit.phar"/>
-->
<!--
Use this when the tools are managed by Composer in ${basedir}/vendor/bin
<property name="phpunit" value="${basedir}/vendor/bin/phpunit"/>
-->
<target name="full-build" depends="prepare,lint,phpunit,-check-failure" description="Performs static analysis, runs the tests, and generates project documentation"/>
<!--
Adjust the threadCount attribute's value to the number of CPUs
-->
<target name="clean" unless="clean.done" description="Cleanup build artifacts">
<delete dir="${basedir}/build/api"/>
<delete dir="${basedir}/build/coverage"/>
<delete dir="${basedir}/build/logs"/>
<property name="clean.done" value="true"/>
</target>
<target name="prepare" unless="prepare.done" depends="clean" description="Prepare for build">
<mkdir dir="${basedir}/build/api"/>
<mkdir dir="${basedir}/build/coverage"/>
<mkdir dir="${basedir}/build/logs"/>
<property name="prepare.done" value="true"/>
</target>
<target name="lint" unless="lint.done" description="Perform syntax check of sourcecode files">
<apply executable="/pkg/vddfg/php/bin/php" taskname="lint">
<arg value="-l"/>
<fileset dir="${basedir}/Symfony/src">
<include name="**/*.php"/>
<modified/>
</fileset>
<fileset dir="${basedir}/Symfony/src">
<include name="**/*.twig"/>
<modified/>
</fileset>
<fileset dir="${basedir}/tests">
<include name="**/*.php"/>
<modified/>
</fileset>
</apply>
<property name="lint.done" value="true"/>
</target>
<target name="phpunit" unless="phpunit.done" depends="prepare" description="Run unit tests with PHPUnit">
<exec executable="${phpunit}" resultproperty="result.phpunit" taskname="phpunit">
<arg value="--configuration"/>
<arg path="${basedir}/build/phpunit.xml"/>
</exec>
<property name="phpunit.done" value="true"/>
</target>
<target name="phpunit-no-coverage" unless="phpunit.done" depends="prepare" description="Run unit tests with PHPUnit (without generating code coverage reports)">
<exec executable="/pkg/vddfg/php/bin/phpunit" failonerror="true" taskname="phpunit">
<arg value="--configuration"/>
<arg path="${basedir}/build/phpunit.xml"/>
<arg value="--no-coverage"/>
</exec>
<property name="phpunit.done" value="true"/>
</target>
<target name="-check-failure">
<fail message="PHPUnit did not finish successfully">
<condition>
<not>
<equals arg1="${result.phpunit}" arg2="0"/>
</not>
</condition>
</fail>
</target>
</project>
当我触发Jenkins作业时,我的ANT作业失败,并显示以下错误消息:
执行失败:java.io.IOException:无法运行程序“ phpunit”(在 目录“ / home / jenkins / workspace”):错误= 2,没有此类文件或 目录
我也尝试通过在build.xml中提供phpunit路径,然后得到一条错误消息:
[phpunit] / usr / bin / env:没有这样的文件或目录
如何解决此问题?