jenkins设置一个php项目 - 日志中的错误

时间:2013-05-01 14:24:14

标签: php jenkins phpunit jenkins-plugins phpmd

所以使用jenkins-php.org我尝试设置一个项目。不幸的是我收到错误。首先,我在哪里放置它要求的那些xml配置文件(phpmd和phpcd)?我可以使用一些标准配置作为起点吗?

但最突出的是日志结尾发生了什么?如何修复该错误?

Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/MyDemo/workspace
Checkout:workspace / /var/lib/jenkins/jobs/MyDemo/workspace - hudson.remoting.LocalChannel@de895e
Using strategy: Default
Last Built Revision: Revision 3653bdb (origin/master, origin/HEAD)
Fetching changes from 1 remote Git repository
Fetching upstream changes from origin
Seen branch in repository origin/HEAD
Seen branch in repository origin/master
Commencing build of Revision 9e40e86 (origin/master, origin/HEAD)
Checking out Revision 9e40e86 (origin/master, origin/HEAD)
Warning : There are multiple branch changesets here
[workspace] $ ant
Buildfile: /var/lib/jenkins/jobs/MyDemo/workspace/build.xml

clean:
[delete] Deleting directory /var/lib/jenkins/jobs/MyDemo/workspace/build/api
[delete] Deleting directory /var/lib/jenkins/jobs/MyDemo/workspace/build/code-browser
[delete] Deleting directory /var/lib/jenkins/jobs/MyDemo/workspace/build/coverage
[delete] Deleting directory /var/lib/jenkins/jobs/MyDemo/workspace/build/logs
[delete] Deleting directory /var/lib/jenkins/jobs/MyDemo/workspace/build/pdepend

prepare:
[mkdir] Created dir: /var/lib/jenkins/jobs/MyDemo/workspace/build/api
[mkdir] Created dir: /var/lib/jenkins/jobs/MyDemo/workspace/build/code-browser
[mkdir] Created dir: /var/lib/jenkins/jobs/MyDemo/workspace/build/coverage
[mkdir] Created dir: /var/lib/jenkins/jobs/MyDemo/workspace/build/logs
[mkdir] Created dir: /var/lib/jenkins/jobs/MyDemo/workspace/build/pdepend

lint:

phploc:
[exec] phploc 1.7.4 by Sebastian Bergmann.
[exec]
[exec] Lines of Code (LOC): 9
[exec] Cyclomatic Complexity / Lines of Code: 0.11
[exec] Comment Lines of Code (CLOC): 0
[exec] Non-Comment Lines of Code (NCLOC): 9
[exec]
[exec] Namespaces: 0
[exec] Interfaces: 0
[exec] Traits: 0
[exec] Classes: 1
[exec] Abstract: 0 (0.00%)
[exec] Concrete: 1 (100.00%)
[exec] Average Class Length (NCLOC): 7
[exec] Methods: 1
[exec] Scope:
[exec] Non-Static: 1 (100.00%)
[exec] Static: 0 (0.00%)
[exec] Visibility:
[exec] Public: 1 (100.00%)
[exec] Non-Public: 0 (0.00%)
[exec] Average Method Length (NCLOC): 7
[exec] Cyclomatic Complexity / Number of Methods: 2.00
[exec]
[exec] Anonymous Functions: 0
[exec] Functions: 0
[exec]
[exec] Constants: 0
[exec] Global constants: 0
[exec] Class constants: 0

pdepend:
[exec] PHP_Depend 1.1.0 by Manuel Pichler
[exec]
[exec] Parsing source files:
[exec] . 1
[exec]
[exec] Executing Coupling-Analyzer:
[exec] 4
[exec]
[exec] Executing CyclomaticComplexity-Analyzer:
[exec] 4
[exec]
[exec] Executing Dependency-Analyzer:
[exec] 3
[exec]
[exec] Executing Inheritance-Analyzer:
[exec] 2
[exec]
[exec] Executing NodeCount-Analyzer:
[exec] 3
[exec]
[exec] Executing NodeLoc-Analyzer:
[exec] 4
[exec]
[exec] Generating pdepend log files, this may take a moment.
[exec]
[exec] Time: 00:00; Memory: 3.00Mb

phpmd-ci:
[exec] Cannot find specified rule-set "/var/lib/jenkins/jobs/MyDemo/workspace/build/phpmd.xml".
[exec] Result: 1

phpcs-ci:
[exec] Result: 2

phpcpd:
[exec] phpcpd 1.4.1 by Sebastian Bergmann.
[exec]
[exec] 0.00% duplicated lines out of 9 total lines of code.
[exec]
[exec] Time: 0 seconds, Memory: 0.75Mb

phpunit:
[exec] PHPUnit 3.7.19 by Sebastian Bergmann.
[exec]
[exec] Configuration read from /var/lib/jenkins/jobs/MyDemo/workspace/phpunit.xml.dist
[exec]
[exec] .
[exec]
[exec] Time: 0 seconds, Memory: 3.00Mb
[exec]
[exec] OK (1 test, 1 assertion)
[exec]
[exec] Generating code coverage report in Clover XML format ... done
[exec]
[exec] Generating code coverage report in HTML format ... done

phpcb:
[exec] [Warning] Could not read file '/var/lib/jenkins/jobs/MyDemo/workspace/build/logs/pmd.xml'. Make sure it contains valid xml.

build:

BUILD SUCCESSFUL
Total time: 4 seconds
[CHECKSTYLE] Collecting checkstyle analysis files...
[CHECKSTYLE] Finding all files that match the pattern build/logs/checkstyle.xml
[PMD] Collecting PMD analysis files...
[PMD] Finding all files that match the pattern build/logs/pmd.xml
[PMD] Parsing 1 files in /var/lib/jenkins/jobs/MyDemo/workspace
[PMD] Skipping file of module /var/lib/jenkins/jobs/MyDemo/workspace/build/logs/pmd.xml because it's empty.
[DRY] Collecting duplicate code analysis files...
[DRY] Finding all files that match the pattern build/logs/pmd-cpd.xml
[DRY] Parsing 1 files in /var/lib/jenkins/jobs/MyDemo/workspace
[DRY] Successfully parsed file /var/lib/jenkins/jobs/MyDemo/workspace/build/logs/pmd-cpd.xml of module with 0 warnings.
Recording plot data
Publishing Clover coverage report...
Publishing Clover HTML report...
Publishing Clover XML report...
Publishing Clover coverage results...
[htmlpublisher] Archiving HTML reports...
[htmlpublisher] Archiving at BUILD level /var/lib/jenkins/jobs/MyDemo/workspace/build/api to /var/lib/jenkins/jobs/MyDemo/builds/2013-04-26_23-54-18/htmlreports/API_Documentation
ERROR: Directory '/var/lib/jenkins/jobs/MyDemo/workspace/build/api' exists but failed copying to '/var/lib/jenkins/jobs/MyDemo/builds/2013-04-26_23-54-18/htmlreports/API_Documentation'.
ERROR: This is especially strange since your build otherwise succeeded.
Build step 'Publish HTML reports' changed build result to FAILURE
[xUnit] [INFO] - Starting to record.
[xUnit] [INFO] - Processing PHPUnit-3.x (default)
[xUnit] [INFO] - [PHPUnit-3.x (default)] - 1 test report file(s) were found with the pattern 'build/logs/junit.xml' relative to '/var/lib/jenkins/jobs/MyDemo/workspace' for the testing framework 'PHPUnit-3.x (default)'.
[xUnit] [INFO] - Check 'Failed Tests' threshold.
[xUnit] [INFO] - Check 'Skipped Tests' threshold.
[xUnit] [INFO] - Setting the build status to FAILURE
[xUnit] [INFO] - Stopping recording.
[JDepend] JDepend plugin is ready
[JDepend] Found 1 classes in 1 packages
ERROR: Publisher hudson.plugins.violations.ViolationsPublisher aborted due to exception
java.io.EOFException: input contained no data
at org.xmlpull.mxp1.MXParser.fillBuf(MXParser.java:3003)
at org.xmlpull.mxp1.MXParser.more(MXParser.java:3046)
at org.xmlpull.mxp1.MXParser.parseProlog(MXParser.java:1410)
at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1395)
at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)
at hudson.plugins.violations.parse.AbstractParser.expectNextTag(AbstractParser.java:262)
at hudson.plugins.violations.types.pmd.PMDParser.execute(PMDParser.java:39)
at hudson.plugins.violations.parse.AbstractTypeParser.parse(AbstractTypeParser.java:57)
at hudson.plugins.violations.ViolationsCollector.doType(ViolationsCollector.java:187)
at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:114)
at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:25)
at hudson.FilePath.act(FilePath.java:904)
at hudson.FilePath.act(FilePath.java:877)
at hudson.plugins.violations.ViolationsPublisher.perform(ViolationsPublisher.java:74)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:802)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:774)
at hudson.model.Build$BuildExecution.post2(Build.java:183)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:724)
at hudson.model.Run.execute(Run.java:1600)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:237)
Finished: FAILURE

3 个答案:

答案 0 :(得分:2)

对于您的配置文件,您可以从http://jenkins-php.org站点复制它们的代码。在页面的大约3/4处有PHPUnit,phpDox,PHP_CodeSniffer和PHPMD的例子。

至于放置文件的位置,您可以将作业配置为几乎在任何地方查找它们,但IIRC默认是将它们放在项目根目录的构建文件夹中。

我们的项目根目录看起来像这样

root
|-- build...
|   |-- phpmd.xml
|   `-- phpunit.xml
`-- src ...
|   |-- our PHP applications code
|   `-- ...
`-- build.xml

如果您将配置文件全部排序并且仍然存在错误,我会查看权限问题,同时也知道运行的操作系统以及安装Jenkins的方式可能有所帮助(Apt包与手动下载和安装)< / p>

答案 1 :(得分:1)

您的第一个例外是

phpmd-ci:
[exec] Cannot find specified rule-set "/var/lib/jenkins/jobs/MyDemo/workspace/build/phpmd.xml".
[exec] Result: 1

我认为这个配置文件已经过时了。这就是找不到规则集的原因。 我能够通过在那里定义规则集来更改build.xml文件来解决它。

原始phpmd配置:

<target name="phpmd-ci" description="Perform project mess detection using PHPMD creating a log file for the continuous integration server">
  <exec executable="phpmd">
   <arg path="${basedir}/src" />
   <arg value="xml" />
   <arg value="${basedir}/build/phpmd.xml" />
   <arg value="--reportfile" />
   <arg value="${basedir}/build/logs/pmd.xml" />
  </exec>
 </target>

更改了配置:

<target name="phpmd-ci" description="Perform project mess detection using PHPMD creating a log file for the continuous integration server">
  <exec executable="phpmd">
    <arg path="${basedir}/src" />
    <arg value="xml" />         
    <arg value="codesize,unusedcode,naming,design" />
    <arg value="--reportfile" />
    <arg value="${basedir}/build/logs/pmd.xml" />
   </exec>
</target>  

phpmd现在将生成一个报告文件,您的上一个例外也将得到解决。

答案 2 :(得分:0)

尝试创建文件 phpdox.xml 以下内容:

<?xml version="1.0" encoding="utf-8" ?>
<phpdox xmlns="http://xml.phpdox.net/config">
    <project name="phpdox" source="../library" workdir="../build/phpdox">
        <collector publiconly="false">
            <include mask="../**/*.php" />
            <exclude mask="../vendor/**"/>
            <exclude mask="*Autoload.php" />
        </collector>

        <generator output="../build">
            <build engine="html" enabled="true" output="api">
                <file extension="html" />
            </build>
        </generator>
    </project>
</phpdox>

我希望它可以帮到你。