From d0cb942f39e8a0b4e90792d3be531891ff33e185 Mon Sep 17 00:00:00 2001 From: sdarwin Date: Mon, 17 Mar 2025 11:20:23 -0600 Subject: [PATCH] git timeout --- posix/clone | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/posix/clone b/posix/clone index 0248a26..e055f02 100755 --- a/posix/clone +++ b/posix/clone @@ -88,17 +88,24 @@ case $DRONE_COMMIT_REF in esac git_clone_retry(){ - retries="${PLUGIN_RETRIES:-0}" + retries="${PLUGIN_RETRIES:-5}" + timeout="${PLUGIN_TIMEOUT:-300}" if [ -n "${retries##*[0-9]*}" ] || [ "${retries}" -lt 0 ]; then echo "PLUGIN_RETRIES defined but is not a number: ${retries}" >&2 exit 1 fi + if [ -n "${timeout##*[0-9]*}" ] || [ "${timeout}" -lt 0 ]; then + echo "PLUGIN_TIMEOUT defined but is not a number: ${timeout}" >&2 + exit 1 + fi - echo "Cloning with ${retries} retries" + echo "Cloning with ${retries} retries, ${timeout}s timeout" n=0 - until [ "$n" -gt "${retries}" ]; do - $1 && return - n=$((n+1)) + until [ "$n" -gt "${retries}" ]; do + echo "$DRONE_STAGE_MACHINE attempt $((n+1))" + timeout $timeout $1 && return + sleep 15 + n=$((n+1)) done exit 1 @@ -114,4 +121,4 @@ tag) *) git_clone_retry clone-commit ;; -esac \ No newline at end of file +esac