about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xconfig.sh4
-rwxr-xr-xdscip13
-rwxr-xr-xfailed.sh18
3 files changed, 30 insertions, 5 deletions
diff --git a/config.sh b/config.sh
index 8d19ad6..342ff83 100755
--- a/config.sh
+++ b/config.sh
@@ -17,8 +17,10 @@ export WORKING_DIRECTORY
 export DSCIP_PRE_CMD="$WORKING_DIRECTORY/pre.sh"
 # Commands to run to build program. #
 export DSCIP_BUILD_CMD="$WORKING_DIRECTORY/build.sh"
-# Commands to run after building is done. #
+# Commands to run after building has succeeded. #
 export DSCIP_POST_CMD="$WORKING_DIRECTORY/post.sh"
+# Commands to run after building has failed.
+export DSCIP_FAILED_CMD="$WORKING_DIRECTORY/failed.sh"
 # Daemon mode options #
 export DSCIP_DAEMON="false" # If daemon mode should be enabled or not. #
 export DSCIP_DAEMON_FORK="true" # If the daemon should run in the background. #
diff --git a/dscip b/dscip
index 6e3adbf..275648d 100755
--- a/dscip
+++ b/dscip
@@ -63,6 +63,7 @@ build () {
 		echo "DSCIP_PRE_CMD=$DSCIP_PRE_CMD";
 		echo "DSCIP_BUILD_CMD=$DSCIP_BUILD_CMD";
 		echo "DSCIP_POST_CMD=$DSCIP_POST_CMD";
+		echo "DSCIP_FAILED_CMD=$DSCIP_FAILED_CMD";
 		echo "DSCIP_DAEMON=$DSCIP_DAEMON";
 		echo "DSCIP_DAEMON_FORK=$DSCIP_DAEMON_FORK";
 		echo "DSCIP_SLEEP=$DSCIP_SLEEP";
@@ -90,10 +91,14 @@ build () {
 		"$DSCIP_PRE_CMD";
 		echo "Running build commands...";
 		cd "$WORKING_DIRECTORY/wrkdir";
-		"$DSCIP_BUILD_CMD";
-		echo "Running post-build commands...";
-		cd "$WORKING_DIRECTORY/wrkdir";
-		"$DSCIP_POST_CMD";
+		if "$DSCIP_BUILD_CMD"; then
+			echo "Running post-build commands...";
+			cd "$WORKING_DIRECTORY/wrkdir";
+			"$DSCIP_POST_CMD";
+		else
+			echo "Build failed. Running failure commands...";
+			"$DSCIP_FAILED_CMD";
+		fi
 	} >> "$DSCIP_OUTPUT_TO" 2>&1
 	echo "$CURRENT_COMMIT" > "$WORKING_DIRECTORY/LAST_COMMIT" # Save commit #
 }
diff --git a/failed.sh b/failed.sh
new file mode 100755
index 0000000..524f16c
--- /dev/null
+++ b/failed.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+set -eu
+
+# This script determines what to do if the build failed.
+# Below is an example of uploading the output.txt to an ftp server.
+ftp -in <<EOF
+open 192.168.1.5
+mkdir $DSCIP_NAME
+cd $DSCIP_NAME
+mkdir $CURRENT_NAME
+cd $CURRENT_NAME
+mkdir $(uname)
+cd $(uname)
+put $WORKING_DIRECTORY/output.txt output-failed.txt
+close
+bye
+EOF