Using Jenkins and Php Code Sniffer Using Jenkins and Php Code Sniffer jenkins jenkins

Using Jenkins and Php Code Sniffer


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.


I believe that the reason you're having issues when running the command in Jenkins (ant) is because of the wildcard asterisk you're using. The wildcard is expanded by the linux shell, but not by ant.

Try removing the wildcard.

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

If you're concerned that phpcs will run against non-php files, you can pass an extensions parameter: http://pear.php.net/manual/en/package.php.php-codesniffer.advanced-usage.php

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

Though, by default phpcs only checks .inc and .php files anyhow.