Mac上的Jenkins:无法运行程序“pdepend”

时间:2012-11-02 23:05:20

标签: macos ant jenkins phpunit

每当我尝试运行构建时,我会得到一堆这样的行:

/Users/Shared/Jenkins/Home/jobs/dghhtreew/workspace/build.xml:28:
The following error occurred while executing this line:
/Users/Shared/Jenkins/Home/jobs/dghhtreew/workspace/build.xml:39: Execute failed: java.io.IOException: Cannot run program "pdepend": error=2, No such file or directory

这是我的build.xml中的相关部分,它是由PHP Project Wizard自动生成的:

...
 <target name="parallelTasks" description="Run the pdepend, phpmd, phpcpd, phpcs, phpdoc and phploc tasks in parallel using a maximum of 2 threads.">
  <parallel threadCount="2">
   <sequential>
    <antcall target="pdepend"/>
    <antcall target="phpmd"/>
   </sequential>
   <antcall target="phpcpd"/>
   <antcall target="phpcs"/>
   <antcall target="phpdoc"/>
   <antcall target="phploc"/>
  </parallel>
 </target>
 <target name="pdepend" description="Generate jdepend.xml and software metrics charts using PHP_Depend">
  <exec executable="pdepend">
   <arg line="--jdepend-xml=${basedir}/build/logs/jdepend.xml
              --jdepend-chart=${basedir}/build/pdepend/dependencies.svg
              --overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg
              ${source}" />
  </exec>
 </target>
... 

显然Jenkins用户找不到这些命令或其他东西。当我通过终端登录Jenkins时:

sudo -s -H -u jenkins 

并尝试pdepend它按预期工作。但出于某种原因,它从Jenkins服务器执行时无法工作。我尝试在可执行行中设置绝对路径,但我得到了相同的结果。我没有对安装或任何事情搞砸了,我通过mac installer获得了Jenkins的最新版本(1.488)。

为什么jenkins不能做任何事情?

2 个答案:

答案 0 :(得分:2)

这是exec任务的执行路径问题。尝试指定pdepend命令的完整路径。

  <exec executable="/complete/path/to/command/pdepend">
  ..

更新

如果仍然无效,请检查 pdepend 命令的权限,以确保它可由jenkins用户执行。

直接运行pdepend命令时,还需要检查返回码:

sudo -u jenkins /complete/path/to/command/pdepend || echo non-zero return code

答案 1 :(得分:0)

也许你没有安装命令,所以对我来说最简单的方法是通过作曲家:

composer global require 'pdepend/pdepend=*'

如果你没有作曲家,请安装它:

curl -sS https://getcomposer.org/installer | php

php composer.phar global require 'pdepend/pdepend=*'

Jenkins允许使用广告路径变量,您不需要添加路径

  1. 请点击&#34;管理Jenkins&#34;
  2. 单击“配置系统”
  3. 查找复选框&#34;环境变量&#34;并确保已选中
  4. 添加新内容: 名称:PATH 价值:$ PATH:/Users/YOUR_USER/.composer/vendor/bin