Skip to content

Commit 3f0bbdb

Browse files
committed
ci-build.sh: give hints when the build goes wrong
In particular, people get javadoc errors a lot, which are confusing because when even a single javadoc error happens, Maven's javadoc plugin logs every javadoc *error and warning* at error level, resulting in the dreaded [ERROR] prefix all over all the javadoc output, burying the actual javadoc errors amongst the typically more plentiful warnings. You can actually find these errors though, because they are prefixed with 'error:' rather than 'warning:'. So we now grep them out and regurgitate them after declaring the build failed, as a helpful hint to why the failure occurred. And if no javadoc-specific errors are found, then we grep for common words indicating error or failure, and regurgitate those instead. And if none of those keywords are found, we declare failure at helping. This commit is dedicated to Nicolas Chiaruttini.
1 parent f0b105e commit 3f0bbdb

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

ci-build.sh

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,35 @@ checkSuccess() {
1919
# Log non-zero exit code.
2020
test $1 -eq 0 || echo "==> FAILED: EXIT CODE $1" 1>&2
2121

22+
if [ $1 -ne 0 -a -f "$2" ]
23+
then
24+
# The operation failed and a log file was provided.
25+
# Do some heuristics, because we like being helpful!
26+
javadocErrors=$(grep error: "$2")
27+
generalErrors=$(grep -i '\b\(errors\?\|fail\|failures\?\)\b' "$2")
28+
if [ "$javadocErrors" ]
29+
then
30+
echo
31+
echo '/----------------------------------------------------------\'
32+
echo '| ci-build.sh analysis: I noticed probable javadoc errors: |'
33+
echo '\----------------------------------------------------------/'
34+
echo "$javadocErrors"
35+
elif [ "$generalErrors" ]
36+
then
37+
echo
38+
echo '/-------------------------------------------------------\'
39+
echo '| ci-build.sh analysis: I noticed the following errors: |'
40+
echo '\-------------------------------------------------------/'
41+
echo "$generalErrors"
42+
else
43+
echo
44+
echo '/----------------------------------------------------------------------\'
45+
echo '| ci-build.sh analysis: I see no problems in the operation log. Sorry! |'
46+
echo '\----------------------------------------------------------------------/'
47+
echo
48+
fi
49+
fi
50+
2251
# Record the first non-zero exit code.
2352
test $success -eq 0 && success=$1
2453
}
@@ -208,19 +237,19 @@ EOL
208237
if [ "$deployOK" -a -f release.properties ]; then
209238
echo
210239
echo "== Cutting and deploying release version =="
211-
mvn $BUILD_ARGS release:perform
212-
checkSuccess $?
240+
BUILD_ARGS="$BUILD_ARGS release:perform"
213241
elif [ "$deployOK" ]; then
214242
echo
215243
echo "== Building and deploying main branch SNAPSHOT =="
216-
mvn -Pdeploy-to-scijava $BUILD_ARGS deploy
217-
checkSuccess $?
244+
BUILD_ARGS="-Pdeploy-to-scijava $BUILD_ARGS deploy"
218245
else
219246
echo
220247
echo "== Building the artifact locally only =="
221-
mvn $BUILD_ARGS install javadoc:javadoc
222-
checkSuccess $?
248+
BUILD_ARGS="$BUILD_ARGS install javadoc:javadoc"
223249
fi
250+
# Check the build result.
251+
{ mvn $BUILD_ARGS; echo $? > exit-code; } | tee mvn-log
252+
checkSuccess "$(cat exit-code)" mvn-log
224253

225254
# --== POST-BUILD ACTIONS ==--
226255

0 commit comments

Comments
 (0)