We are seeing a sporadic failure in our nightly builds due to the git clone/fetch calls timing out and erroring. These events are usually resolved by just trying the git call again, but in a scripted flow it causes a failure in that run. The git_retry.sh script solves that by allowing the git command to be retried a few times while sleeping in between.
Signed-off-by: Ryan Eatmon <[email protected]> --- git_retry.sh | 29 +++++++++++++++++++++++++++++ oe-layertool-setup.sh | 4 ++-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100755 git_retry.sh diff --git a/git_retry.sh b/git_retry.sh new file mode 100755 index 0000000..e5ed5bb --- /dev/null +++ b/git_retry.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +let glRetries=5 +let glDelay=15 +let glExitCode=0 + +while [ $glRetries -gt 0 ]; do + + git "$@" + + glExitCode=$? + + if [ $glExitCode -eq 0 ]; then + exit + fi + + let glRetries=$glRetries-1 + + if [ $glRetries -gt 0 ]; then + echo "git failed... remaining attempts: $glRetries" + sleep $glDelay + fi + +done + +echo "git failed... giving up..." + +exit $glExitCode + diff --git a/oe-layertool-setup.sh b/oe-layertool-setup.sh index df1523f..932ec49 100755 --- a/oe-layertool-setup.sh +++ b/oe-layertool-setup.sh @@ -336,9 +336,9 @@ clone_repo() { if [ -d $sourcedir/$name ] then cd $sourcedir/$name - git fetch --all + $oebase/git_retry.sh fetch --all else - git clone $uri $sourcedir/$name + $oebase/git_retry.sh clone $uri $sourcedir/$name if [ "$?" != "0" ] then echo "ERROR: Could not clone repository at $uri" -- 2.17.1 -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#13480): https://lists.yoctoproject.org/g/meta-arago/message/13480 Mute This Topic: https://lists.yoctoproject.org/mt/88731649/21656 Group Owner: [email protected] Unsubscribe: https://lists.yoctoproject.org/g/meta-arago/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
