blob: 3f9ce37fc25b5827be9a6f83a9eb3f47fe15d910 [file]
<project
default="checkForFastFail"
basedir=".">
<target name="checkForFastFail">
<property
name="resource"
value="${env.LOG_DIR}/${projectname}/antBuilderOutput.log"/>
<!--
<property
name="resource"
value="/opt/public/webtools/committers/wtp-R3.3.0-I/20110308135648/I-3.3.0-20110308135648/antBuilderOutput.log"/>
-->
<echo message="log file to check for failures: ${resource}"/>
<!-- remember to quote any grep special characters, such as bracket ([) -->
<antcall target="checkForString">
<param
name="stringToCheck"
value="cvs \[export aborted\]\:"/>
<param
name="shortDescription"
value="Problem with CVS checkout. Check tag. Perhaps network. "/>
</antcall>
<!-- note use of wild card (.) since can not embbed apostophe (') in so many other quotes and apostrophes -->
<antcall target="checkForString">
<param
name="stringToCheck"
value="\[get\] Can.t get http"/>
<param
name="shortDescription"
value="Problem getting prereq via http. Check name or spelling. "/>
</antcall>
<antcall target="checkForString">
<param
name="stringToCheck"
value="BUILD FAILED"/>
<param
name="shortDescription"
value="Generic failure for unknown reasons. See log context. "/>
</antcall>
</target>
<target name="checkForString">
<!-- can not echo string here ... or, next check will find it, instead of real one
<echo message=" Checking for '${stringToCheck}'"/>
-->
<exec
executable="grep"
outputproperty="reasonFailed">
<arg line="--max-count 1 --after-context 10 --before-context 10 --regexp='${stringToCheck}' ${resource}"/>
</exec>
<!-- it appears the exec, at least for grep, returns an empty string if no match
so we follow that check to see if return result has length. TODO: could maybe use return code? -->
<condition
property="reasonFailedText"
value="${reasonFailed}">
<length
string="${reasonFailed}"
trim="true"
when="greater"
length="0"/>
</condition>
<antcall target="copyAndFailIfReason"/>
</target>
<target
name="copyAndFailIfReason"
if="reasonFailedText">
<property
name="formatedReasonFailedText"
value="FAST FAIL CHECK found matching string '${stringToCheck}'${line.separator}----------------${line.separator}Context of matching text leading to fast fail: ${line.separator}----------------${line.separator}${reasonFailedText}${line.separator}----------------${line.separator}"/>
<!-- be sure to echo reason msg to log -->
<!-- TODO: we could write this to a file, and make available from download page -->
<echo message="FAST FAIL CHECK found reason to end build: ${shortDescription}"/>
<echo message="${formatedReasonFailedText}"/>
<!-- copy early, if we can ... else site won't be created, when we fail -->
<ant antfile="${wtp.builder.home}/scripts/build/copyArtifactsEarly.xml"/>
<fail message="${shortDescription}"/>
</target>
</project>