Add retries
option (#43)
* Add `retries` option It can be enabled this way: ``` clone: retries: 3 ```
This commit is contained in:
parent
3ccd78325a
commit
8070857203
23
posix/clone
23
posix/clone
@ -87,14 +87,31 @@ case $DRONE_COMMIT_REF in
|
|||||||
refs/merge-requests/* ) CLONE_TYPE=pull_request ;;
|
refs/merge-requests/* ) CLONE_TYPE=pull_request ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
git_clone_retry(){
|
||||||
|
retries="${PLUGIN_RETRIES:-0}"
|
||||||
|
if [ -n "${retries##*[0-9]*}" ] || [ "${retries}" -lt 0 ]; then
|
||||||
|
echo "PLUGIN_RETRIES defined but is not a number: ${retries}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Cloning with ${retries} retries"
|
||||||
|
n=0
|
||||||
|
until [ "$n" -gt "${retries}" ]; do
|
||||||
|
$1 && return
|
||||||
|
n=$((n+1))
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
case $CLONE_TYPE in
|
case $CLONE_TYPE in
|
||||||
pull_request)
|
pull_request)
|
||||||
clone-pull-request
|
git_clone_retry clone-pull-request
|
||||||
;;
|
;;
|
||||||
tag)
|
tag)
|
||||||
clone-tag
|
git_clone_retry clone-tag
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
clone-commit
|
git_clone_retry clone-commit
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
Loading…
Reference in New Issue
Block a user