From 880da2f5178d449e7c7484ff931bb1b9f93f1b8a Mon Sep 17 00:00:00 2001 From: Hari Sekhon Date: Fri, 10 Apr 2020 12:19:50 +0100 Subject: [PATCH] added trap_function support and auto CI trap function of docker_image_cleanup --- lib/utils.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/utils.sh b/lib/utils.sh index 5cf97baa..e534948b 100755 --- a/lib/utils.sh +++ b/lib/utils.sh @@ -291,8 +291,16 @@ print_debug_env(){ trap_debug_env(){ local name name="$1" + # stop CI systems from running out of space due to accumulated docker images as that causes build failures + if is_CI && + ! type trap_function &>/dev/null && + type docker_image_cleanup; then + trap_function(){ + docker_image_cleanup + } + fi # shellcheck disable=SC2086,SC2154 - trap 'result=$?; print_debug_env '"$*"'; untrap; exit $result' $TRAP_SIGNALS + trap 'result=$?; type trap_function >/dev/null 2>/dev/null && trap_function; print_debug_env '"$*"'; untrap; exit $result' $TRAP_SIGNALS } pass(){