antのmodifiedセレクタ
Template for Jenkins Jobs for PHP Projects
を試してます。antのbuild.xmlを手書きするのなんて何年ぶりだろう。
<target name="lint" description="Perform syntax check of sourcecode files"> <apply executable="php" failonerror="true"> <arg value="-l" /> <fileset dir="${basedir}/src"> <include name="**/*.php" /> <modified /> </fileset> <fileset dir="${basedir}/tests"> <include name="**/*.php" /> <modified /> </fileset> </apply> </target>
この部分。modifiedセレクタはcache.propertiesというファイルにファイル名とダイジェスト値を保存して、その値と違っているファイルのみを選択するのですが、これphp -lが失敗してもcache.propertiesは更新されてしまうらしく、Syntax Errorが発生してビルドが失敗しても、そのファイルをそのままに他のファイルを更新してもう一度ビルドするとビルドが成功してしまう模様。
ビルドが成功した場合はキャッシュファイルをよけておいて、次回のビルドのときにそれを上書きしてビルドする(失敗した場合はキャッシュファイルがコピーされていないので、常に最後に成功したビルドのキャッシュファイルが使われる)とすればできそうな気がするけど、そんな方法しかないんだろうか。
<target name="lint" depends="lint-pre,lint-do,lint-post" description="Perform syntax check of sourcecode files" /> <target name="lint-pre"> <delete file="cache.properties" /> <move file="cache.properties.success" tofile="cache.properties" overwrite="true" failonerror="false" /> </target> <target name="lint-post"> <move file="cache.properties" tofile="cache.properties.success" /> </target> <target name="lint-do"> <apply executable="php" failonerror="true"> .. </apply> </target>