Merge pull request #96 from apache/feature/build-error-detection

Detect JBake execution failures
diff --git a/bake.sh b/bake.sh
index b781bc6..2199ca6 100755
--- a/bake.sh
+++ b/bake.sh
@@ -1,5 +1,6 @@
 #!/bin/sh
 
+SUCCESS_FILE=$WORKDIR/.htaccess
 if [ -z ${JBAKE_HOME} ]
 then
   echo "Missing JBAKE_HOME variable" >&2
@@ -8,3 +9,9 @@
 
 export JBAKE_OPTS="-Djavax.xml.accessExternalDTD=http"
 ${JBAKE_HOME}/bin/jbake $@
+
+if [ ! -f $SUCCESS_FILE ]
+then
+    echo "Missing $SUCCESS_FILE , JBake build failed?" >&2
+    exit 1
+fi
\ No newline at end of file
diff --git a/build_local.sh b/build_local.sh
index deac81a..9de8fee 100755
--- a/build_local.sh
+++ b/build_local.sh
@@ -1,11 +1,16 @@
 #!/bin/bash
 
 CURRENTDIR=`pwd`
-WORKDIR=/tmp/incubator-site
+export WORKDIR=/tmp/incubator-site
+
+function fatal() {
+    echo $* >&2
+    exit 1
+}
 
 rm -rf $WORKDIR
 mkdir -p $WORKDIR
 
 # just bake and serve the site
-./bake.sh -b -s . $WORKDIR
+./bake.sh -b -s . $WORKDIR || fatal "Build failed, exiting"
 
diff --git a/build_site.sh b/build_site.sh
index b345785..725aae4 100755
--- a/build_site.sh
+++ b/build_site.sh
@@ -1,14 +1,19 @@
 #!/bin/bash
 
 CURRENTDIR=`pwd`
-WORKDIR=/tmp/incubator-site
+export WORKDIR=/tmp/incubator-site
 ME=`basename $0`
 
+function fatal() {
+    echo $* >&2
+    exit 1
+}
+
 rm -rf $WORKDIR
 mkdir -p $WORKDIR
 
 # now bake the site
-./bake.sh -b . $WORKDIR
+./bake.sh -b . $WORKDIR || fatal "Build failed, exiting"
 
 # push all of the results to asf-site
 git checkout asf-site