加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

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

发布时间:2020-12-14 04:18:20 所属栏目:Windows 来源:网络整理
导读:我最近在我的本地 Windows 7开发环境中安装了Jenkins. 我为我的本地Java和Ant安装配置了Jenkins,并设置了我的第一个项目. 我使用http://jenkins-php.org/中的指令在build.xml中指定的构建中执行某些PHP工具(PHP CodeSniffer,PHP Doc等). 在安装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:ServersJenkinsjobsMyProjectworkspacebuild.xml

clean:
   [delete] Deleting directory C:ServersJenkinsjobsMyProjectworkspacebuildapi
   [delete] Deleting directory C:ServersJenkinsjobsMyProjectworkspacebuildcode-browser
   [delete] Deleting directory C:ServersJenkinsjobsMyProjectworkspacebuildcoverage
   [delete] Deleting directory C:ServersJenkinsjobsMyProjectworkspacebuildlogs
   [delete] Deleting directory C:ServersJenkinsjobsMyProjectworkspacebuildpdepend
    [mkdir] Created dir: C:ServersJenkinsjobsMyProjectworkspacebuildapi
    [mkdir] Created dir: C:ServersJenkinsjobsMyProjectworkspacebuildcode-browser
    [mkdir] Created dir: C:ServersJenkinsjobsMyProjectworkspacebuildcoverage
    [mkdir] Created dir: C:ServersJenkinsjobsMyProjectworkspacebuildlogs
    [mkdir] Created dir: C:ServersJenkinsjobsMyProjectworkspacebuildpdepend

parallelTasks:

pdepend:

phpcpd:

phpdoc:

phpcs:

phploc:

BUILD FAILED
C:ServersJenkinsjobsMyProjectworkspacebuild.xml:29: 
The following error occurred while executing this line:
C:ServersJenkinsjobsMyProjectworkspacebuild.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:ServersJenkinsjobsMyProjectworkspacebuild.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:ServersJenkinsjobsMyProjectworkspacebuild.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:ServersJenkinsjobsMyProjectworkspacebuild.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:ServersJenkinsjobsMyProjectworkspacebuild.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:ServersJenkinsjobsMyProjectworkspacebuild/code-browser to C:ServersJenkinsjobsMyProjecthtmlreportsCode_Browser
ERROR: Directory 'C:ServersJenkinsjobsMyProjectworkspacebuild/code-browser' exists but failed copying to 'C:ServersJenkinsjobsMyProjecthtmlreportsCode_Browser'.
Publishing Javadoc
[JDepend] JDepend plugin is ready
[JDepend] Couldn't generate JDepend file at 'build/logs/jdepend.xml'java.io.FileNotFoundException: C:ServersJenkinsjobsMyProjectworkspacebuildlogsjdepend.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}libZend*'
            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}libZend*'
          " />
    </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=*libZend*
            -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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读