Windows上的Jenkins CI – 在构建时不执行PHP工具

前端之家收集整理的这篇文章主要介绍了Windows上的Jenkins CI – 在构建时不执行PHP工具前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我最近在我的本地 Windows 7开发环境中安装了Jenkins.

我为我的本地Java和Ant安装配置了Jenkins,并设置了我的第一个项目.

我使用http://jenkins-php.org/中的指令在build.xml中指定的构建中执行某些PHP工具(PHP CodeSniffer,PHP Doc等).

在安装PHP工具包之前正确配置了Pear,因此包的所有package.bat文件(在Pear目录中)都有正确的PHP bin路径.此外,设置了一个Windows环境变量PHPBIN,指向PHP bin位置 – PHP bin路径也在PATH变量上.

Pear路径(包含所有PHP工具的安装)也包含在PATH变量中.

当我手动启动构建时,我收到错误消息,它无法运行某些程序( – > PHP工具),虽然它们已正确安装(通过Pear)并且可通过命令提示符执行…

这是错误输出

Started by user anonymous
Updating file:///D://SVN/MyProjectRepository/trunk/public_html
At revision 38
[workspace] $cmd.exe /C '"ant.bat -file build.xml && exit %%ERRORLEVEL%%"'
Buildfile: C:\Servers\Jenkins\jobs\MyProject\workspace\build.xml

clean:
   [delete] Deleting directory C:\Servers\Jenkins\jobs\MyProject\workspace\build\api
   [delete] Deleting directory C:\Servers\Jenkins\jobs\MyProject\workspace\build\code-browser
   [delete] Deleting directory C:\Servers\Jenkins\jobs\MyProject\workspace\build\coverage
   [delete] Deleting directory C:\Servers\Jenkins\jobs\MyProject\workspace\build\logs
   [delete] Deleting directory C:\Servers\Jenkins\jobs\MyProject\workspace\build\pdepend
    [mkdir] Created dir: C:\Servers\Jenkins\jobs\MyProject\workspace\build\api
    [mkdir] Created dir: C:\Servers\Jenkins\jobs\MyProject\workspace\build\code-browser
    [mkdir] Created dir: C:\Servers\Jenkins\jobs\MyProject\workspace\build\coverage
    [mkdir] Created dir: C:\Servers\Jenkins\jobs\MyProject\workspace\build\logs
    [mkdir] Created dir: C:\Servers\Jenkins\jobs\MyProject\workspace\build\pdepend

parallelTasks:

pdepend:

PHPcpd:

PHPdoc:

PHPcs:

PHPloc:

BUILD Failed
C:\Servers\Jenkins\jobs\MyProject\workspace\build.xml:29: 
The following error occurred while executing this line:
C:\Servers\Jenkins\jobs\MyProject\workspace\build.xml:42: Execute Failed: java.io.IOException: Cannot run program "pdepend": CreateProcess error=2,The system cannot find the file specified
The following error occurred while executing this line:
C:\Servers\Jenkins\jobs\MyProject\workspace\build.xml:62: Execute Failed: java.io.IOException: Cannot run program "PHPcpd": CreateProcess error=2,The system cannot find the file specified
The following error occurred while executing this line:
C:\Servers\Jenkins\jobs\MyProject\workspace\build.xml:80: Execute Failed: java.io.IOException: Cannot run program "PHPcs": CreateProcess error=2,The system cannot find the file specified
The following error occurred while executing this line:
C:\Servers\Jenkins\jobs\MyProject\workspace\build.xml:93: Execute Failed: java.io.IOException: Cannot run program "PHPdoc": CreateProcess error=2,The system cannot find the file specified
The following error occurred while executing this line:
C:\Servers\Jenkins\jobs\MyProject\workspace\build.xml:72: Execute Failed: java.io.IOException: Cannot run program "PHPloc": CreateProcess error=2,The system cannot find the file specified

Total time: 0 seconds
Build step 'Invoke Ant' marked build as failure
[CHECKSTYLE] Skipping publisher since build result is FAILURE
[PMD] Skipping publisher since build result is FAILURE
[DRY] Skipping publisher since build result is FAILURE
[htmlpublisher] Archiving HTML reports...
[htmlpublisher] Archiving at PROJECT level C:\Servers\Jenkins\jobs\MyProject\workspace\build/code-browser to C:\Servers\Jenkins\jobs\MyProject\htmlreports\Code_Browser
ERROR: Directory 'C:\Servers\Jenkins\jobs\MyProject\workspace\build/code-browser' exists but Failed copying to 'C:\Servers\Jenkins\jobs\MyProject\htmlreports\Code_Browser'.
Publishing Javadoc
[JDepend] JDepend plugin is ready
[JDepend] Couldn't generate JDepend file at 'build/logs/jdepend.xml'java.io.FileNotFoundException: C:\Servers\Jenkins\jobs\MyProject\workspace\build\logs\jdepend.xml (The system cannot find the file specified)
Sending e-mails to: test@localhost
Finished: FAILURE

任何人都可以指出我正确的方向是什么问题?

简短的回答是:在Windows上以不会以某种方式破坏执行或结果的方式设置构建文件是非常痛苦的.这不是Jenkins问题,也不是Ant问题.这是QA工具.如果你有机会将Jenkins移到* nix,那么就这样做.

特别是,在运行PHP QA工具时,请确保使用cmd / c调用它们,例如

<target name="pdepend">
    <exec executable="cmd">
        <arg line="/c pdepend
            --jdepend-xml='${basedir}/build/logs/jdepend.xml'
            … additional options
            sourcefolder1,sourcefolder2
        " />
    </exec>
</target>

还要确保在任何路径中都没有空格,因为它们会导致问题.你也不能可靠地使用〜字符(比如在DOS路径中),各种PHP工具都会有自己关于目录分隔符的想法,以及它们是否将多个源文件夹作为逗号分隔值等.

随意报告您在GitHub上与各种工具所有者遇到的任何错误,以便修复它们.另外,考虑下降到#jenkins-php at Freenode IRC.

查找适合我的构建文件配置示例:

<?xml version="1.0" encoding="utf-8" ?> 
<project name="foo" default="build" basedir=".">

<target name="clean">
    <!-- Clean up -->
    <delete dir="${basedir}/build" />

    <!-- Create build directories -->
    <mkdir dir="${basedir}/build/api" />
    <mkdir dir="${basedir}/build/code-browser" />
    <mkdir dir="${basedir}/build/coverage" />
    <mkdir dir="${basedir}/build/logs" />
    <mkdir dir="${basedir}/build/pdepend" />
</target>

<!-- Run unit tests and generate junit.xml and clover.xml -->
<target name="PHPunit">
    <exec executable="cmd">
        <arg line="/c PHPunit '${basedir}/test'" />
    </exec>
</target>

<!-- Run the pdepend,PHPmd,PHPcpd,PHPcs,PHPdoc and PHPloc tasks in parallel 
    using a maximum of 2 threads. -->
<target name="parallelTasks">
    <parallel threadCount="1">
        <sequential>
            <antcall target="pdepend" />
            <antcall target="PHPmd" />
        </sequential>
        <antcall target="PHPcpd" />
        <antcall target="PHPcs" />
        <antcall target="PHPdoc" />
        <antcall target="PHPloc" />
    </parallel>
</target>

<!-- Generate jdepend.xml and software metrics charts -->
<target name="pdepend">
    <exec executable="cmd">
        <arg line="/c pdepend
            --jdepend-xml='${basedir}/build/logs/jdepend.xml'
            --jdepend-chart='${basedir}/build/pdepend/dependencies.svg'
            --summary-xml='${basedir}/build/logs/jdepend-summary.xml'
            --overview-pyramid='${basedir}/build/pdepend/overview-pyramid.svg'
            --ignore='${basedir}\lib\Zend\*'
            application,lib
            " />
    </exec>
</target>

<!-- Generate pmd.xml -->
<target name="PHPmd">
    <exec executable="cmd">
        <arg line="/c PHPmd application,lib
          xml
          codesize,design,naming,unusedcode
          --reportfile '${basedir}/build/logs/pmd.xml'
          --exclude '${basedir}\lib\Zend\*'
          " />
    </exec>
</target>

<!-- Generate pmd-cpd.xml -->
<target name="PHPcpd">
    <exec executable="cmd">
        <arg line="/c PHPcpd
            --log-pmd '${basedir}/build/logs/pmd-cpd.xml'
            --exclude '${basedir}/lib/Zend'
            application lib" />
    </exec>
</target>

<!-- Generate PHPloc.csv -->
<target name="PHPloc">
    <exec executable="cmd">
        <arg line="/c PHPloc
            --log-csv '${basedir}/build/logs/PHPloc.csv'
            --exclude '${basedir}/lib/Zend'
            application lib" />
    </exec>
</target>

<!-- Generate checkstyle.xml -->
<target name="PHPcs">
    <exec executable="cmd">
        <arg line="/c PHPcs
            --report=checkstyle
            --report-file='${basedir}/build/logs/checkstyle.xml'
            --standard='${basedir}/docs/coding-standard/ruleset.xml'
            --ignore=*\\lib\\Zend\\*
            -p
            application lib" />
    </exec>
</target>

<!-- Generate API documentation -->
<target name="PHPdoc">
    <exec executable="cmd">
        <arg line="/c PHPdoc
            --directory application lib
            --target    '${basedir}/build/api'
            --ignore    '${basedir}/lib/Zend/*'
           " />
    </exec>
</target>

<target name="PHPcb">
    <exec executable="cmd">
        <arg line="/c PHPcb
          --log    '${basedir}/build/logs'
          --output '${basedir}/build/code-browser'
          --ignore '${basedir}/lib/Zend'
          " />

    </exec>
</target>

<target name="build" depends="clean,parallelTasks,PHPunit,PHPcb" />
</project>

猜你在找的Windows相关文章