| <!-- |
| Copyright (c) 2011, 2019 IBM Corporation and others. |
| This program and the accompanying materials |
| are made available under the terms of the Eclipse Public License 2.0 |
| which accompanies this distribution, and is available at |
| https://www.eclipse.org/legal/epl-2.0/ |
| |
| SPDX-License-Identifier: EPL-2.0 |
| |
| Contributors: |
| IBM Corporation - initial API and implementation |
| --> |
| <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"/> |
| --> |
| |
| <!-- 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> |
| |
| <antcall target="checkForString"> |
| <param |
| name="stringToCheck" |
| value="\[p2.repo2runnable\] \[Fatal Error\]"/> |
| <param |
| name="shortDescription" |
| value="P2 fetch or install problem. Check tags? Network? Or ... just re-run."/> |
| </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}'"/> |
| |
| Note that we "capture" errorProperty, in an effort to avoid "error result: 1" being logged |
| to our standard output. Grep returns a "1" if there is no match ... which isn't really an |
| error, but makes output "look funny" seeing so many error codes, especially in CC logs. |
| TODO: we could check if error was greater than or equal to '2', which is somesort of "real" error. |
| --> |
| <exec |
| executable="grep" |
| outputproperty="reasonFailed" |
| resultproperty="returnCode" |
| errorproperty="ignoredErrored" |
| error="${env.LOG_DIR}/${projectname}/grepError.log" |
| failonerror="false"> |
| <arg line="-s --max-count 1 --after-context 20 --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 (-10 to +20 lines, see ${resource} if reason not obvious from context): ${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="Resource being used in fast fail check: ${resource}"/> |
| <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> |