Skip to content

git timeout #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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