reenabling diagnose-build-failure with a short timeout in postsubmit

It will be able to tell us after a failure occurs whether the failure persists to the next build.

If a failure is deterministic then it's more likely to be easily reproducible and easier to investigate

Bug: 187822154
Test: BUILD_NUMBER="P123" ./busytown/androidx_incremental.sh misspelled # and see that this fails and does not try to diagnose the error
Test: BUILD_NUMBER="123" ./busytown/androidx_incremental.sh misspelled # and see that this fails and does try to diagnose the error

Change-Id: I7f7765247f8f2b0d2f5cebe29ea8e241fd34303f
diff --git a/busytown/androidx_incremental.sh b/busytown/androidx_incremental.sh
index d11eb1e..9c29a31 100755
--- a/busytown/androidx_incremental.sh
+++ b/busytown/androidx_incremental.sh
@@ -16,6 +16,12 @@
 export DIST_DIR="$DIST_DIR/incremental"
 mkdir -p "$DIST_DIR"
 
+if echo "$BUILD_NUMBER" | grep "P" >/dev/null; then
+  PRESUBMIT=true
+else
+  PRESUBMIT=false
+fi
+
 function hashOutDir() {
   hashFile=out.hashes
   echo "hashing out dir and saving into $DIST_DIR/$hashFile"
@@ -38,16 +44,23 @@
   echo done zipping kotlin metadata
 }
 
+# If we encounter a failure in postsubmit, we try a few things to determine if the failure is
+# reproducible
+DIAGNOSE_ARG=""
+if [ "$PRESUBMIT" == "false" ]; then
+  DIAGNOSE_ARG="--diagnose"
+fi
+
 # Run Gradle
 EXIT_VALUE=0
-if impl/build.sh buildOnServer checkExternalLicenses listTaskOutputs validateAllProperties \
+if impl/build.sh $DIAGNOSE_ARG buildOnServer checkExternalLicenses listTaskOutputs validateAllProperties \
     --profile "$@"; then
   echo build succeeded
   EXIT_VALUE=0
 else
   zipKotlinMetadata
   echo build failed
-  if echo "$BUILD_NUMBER" | grep "P"; then
+  if [ "$PRESUBMIT" == "true" ]; then
     echo androidx_incremental ignoring presubmit failure
   else
     EXIT_VALUE=1