Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions posix/clone
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -114,4 +121,4 @@ tag)
*)
git_clone_retry clone-commit
;;
esac
esac