summaryrefslogtreecommitdiffstats
path: root/docker/scripts/buildbot_step
diff options
context:
space:
mode:
authorDavid Lawrence <dkl@mozilla.com>2015-11-06 23:21:30 +0100
committerDavid Lawrence <dkl@mozilla.com>2015-11-06 23:21:30 +0100
commitaf46939af5dbe914e07c9b1ec0af2560b38ffbc6 (patch)
treee3614dddfd2dff0a027c59345f70343f76619eb5 /docker/scripts/buildbot_step
parent60bde01b7ffc861a7bfba352af015b2b154e6f1e (diff)
downloadbugzilla-af46939af5dbe914e07c9b1ec0af2560b38ffbc6.tar.gz
bugzilla-af46939af5dbe914e07c9b1ec0af2560b38ffbc6.tar.xz
Bug 1222497 - Refactor the BMO docker image with new file and script structure while minimizing final image size
Diffstat (limited to 'docker/scripts/buildbot_step')
-rw-r--r--docker/scripts/buildbot_step63
1 files changed, 63 insertions, 0 deletions
diff --git a/docker/scripts/buildbot_step b/docker/scripts/buildbot_step
new file mode 100644
index 000000000..a567351b8
--- /dev/null
+++ b/docker/scripts/buildbot_step
@@ -0,0 +1,63 @@
+#! /bin/bash -e
+
+buildbot_step_help() {
+ echo "Run a command and wrap it in buildbot step format"
+ echo " $0 - <buildbot step> [bash args...]"
+}
+
+bb_time() {
+ # Parser dies if this is longer then 6 chars long.
+ nano=$(date +%N | cut -c1-6)
+ echo "$(date '+%Y-%m-%d %H:%M:%S.')$nano"
+}
+
+bb_echo() {
+ echo "========= $1 ========="
+}
+
+bb_line() {
+ local type=$1 # Finished/Started
+ local step=$2 # Name of step
+ local code=$3 # Exit code
+ local duration=$4 # Elapsed time in seconds
+ local time=$(bb_time)
+
+ bb_echo "$type $step (results: $code, elapsed: $duration secs) (at $time)"
+}
+
+# Intentionally the full name of this executable so sourcing this file also
+# works as expected...
+buildbot_step() {
+ local step=$1
+ local command=${@:2}
+ local start_time=$(date +%s)
+ local exit_code=0
+
+ bb_line "Started" "$step" 0 0
+ if eval "$command";
+ then
+ exit_code=$?
+ else
+ exit_code=$?
+ fi
+
+ local end_time=$(date +%s)
+ local duration=$(($end_time-$start_time))
+
+ bb_line "Finished" "$step" $exit_code $duration
+ return $exit_code
+}
+
+
+# When this script is not being sourced invoke command directly.
+if [ "$(basename $0)" == "buildbot_step" ];
+then
+ if [ $# -lt 2 ];
+ then
+ buildbot_step_help
+ exit 1
+ fi
+ buildbot_step "$@"
+ exit $?
+fi
+