Search code examples
phing

Phing task fails due to space in path


When trying to write a php code sniffer log to a path that contains spaces I get this error:

[exec] ERROR: The file "calendar/build/checkstyle-codesniffer.xml" does not exist.

The full path of the file is /home/jenkins/ci/workspace/full calendar/build/checkstyle-codesniffer.xml.

I tried wrapping the report-file in single quotes like this --report-file='${project.basedir}/build/checkstyle-codesniffer.xml'

but that just changed the error to this

[exec] ERROR: The file "/home/jenkins/ci/workspace/full" does not exist.

analyze-phpcs target:

<target name="analyze-phpcs" depends="prepare">
  <exec command="phpcs --report=checkstyle --report-file=${project.basedir}/build/checkstyle-codesniffer.xml --standard=Drupal --extensions=php,module,install,inc,profile,test --ignore=*/contrib/*,*/development/*,*.features.*,*.field_group.*,*.layouts.*,*.pages_default.*,*.panelizer.*,*.panels_default.*,*.strongarm.*,*.views_default.* ${project.basedir}" logoutput="true" />
</target>

prepare target:

<patternset id="php">
  <include name="**/*.php" />
  <include name="**/*.module" />
  <include name="**/*.install" />
  <include name="**/*.inc" />
  <include name="**/*.profile" />
  <include name="**/*.test" />
</patternset>

<patternset id="generated">
  <exclude name="**/*.features.*" />
  <exclude name="**/*.field_group.inc" />
  <exclude name="**/*.layouts.inc" />
  <exclude name="**/*.pages_default.inc" />
  <exclude name="**/*.panelizer.inc" />
  <exclude name="**/*.panels_default.inc" />
  <exclude name="**/*.strongarm.inc" />
  <exclude name="**/*.views_default.inc" />
</patternset>

<patternset id="contrib">
  <exclude name="**/contrib/**/*.*" />
  <exclude name="**/development/**/*.*" />
  <exclude name="**/libraries/**/*.*" />
</patternset>

<fileset id="src.php" dir="${project.basedir}">
  <patternset refid="php"/>
  <patternset refid="generated"/>
  <patternset refid="contrib"/>
</fileset>

Is there a workaround for this? Or am I just doing it wrong?


Solution

  • I found the error. When I added the single quotes around the reportFile parameter it worked and the error output was in regards to the last parameter (which files to analyze).

    So the solution is to add single quotes to this paramter too:

    phpcs --report=checkstyle --report-file='${project.basedir}/build/checkstyle-codesniffer.xml' --standard=Drupal --extensions=php,module,install,inc,profile,test --ignore=*/contrib/*,*/development/*,*.features.*,*.field_group.*,*.layouts.*,*.pages_default.*,*.panelizer.*,*.panels_default.*,*.strongarm.*,*.views_default.* '${project.basedir}'