Using Jenkins and Php Code Sniffer

Stephtheboss picture Stephtheboss · May 21, 2013 · Viewed 9.9k times · Source

I'm trying to use the Php Code Sniffer plugin in Jenkins. It generates a checkstyle.xml file but there are no errors inside, and I know that I should have.

Here's the containt of my checkstyle.xml :

<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="1.5.0RC2">
</checkstyle>

My build.xml file for Jenkins is :

<target name="phpcs" >
  <exec executable="phpcs">
    <arg line="--report=checkstyle 
 --report-file=${project.basedir}/build/logs/checkstyle.xml
 --standard=Zend
 ${project.basedir}/*.php" />
  </exec>
 </target>

And when i do it in command line, I have a different result. My command :

phpcs --report=checkstyle --report-file=checkstyle.xml --standard=Zend *.php

It generates the same checkstyle.xml with no errors, and a phpcs-checkstyle.tmp which contains the errors.

How can I do to have the results with the errors in my checkstyle.xml file ?

Thanks.

Answer

Greg Sherwood picture Greg Sherwood · May 22, 2013

I think your problem is that you are suffering from this bug: http://pear.php.net/bugs/bug.php?id=19930

The bug only occurs in the RC version you are using.

Reverting to the current stable version (1.4.5) should get things working again for you.