mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-20 06:29:50 +00:00
[Ubuntu] Improve errexit option handling (#8352)
This commit is contained in:
committed by
GitHub
parent
953177d098
commit
b3c54ca36b
@@ -19,16 +19,24 @@ download_with_retries() {
|
||||
local COMMAND="curl $URL -4 -sL -o '$DEST/$NAME' -w '%{http_code}'"
|
||||
fi
|
||||
|
||||
# Save current errexit state and disable it to prevent unexpected exit on error
|
||||
if echo $SHELLOPTS | grep '\(^\|:\)errexit\(:\|$\)' > /dev/null;
|
||||
then
|
||||
local ERR_EXIT_ENABLED=true
|
||||
else
|
||||
local ERR_EXIT_ENABLED=false
|
||||
fi
|
||||
set +e
|
||||
|
||||
echo "Downloading '$URL' to '${DEST}/${NAME}'..."
|
||||
retries=20
|
||||
interval=30
|
||||
while [ $retries -gt 0 ]; do
|
||||
((retries--))
|
||||
# Temporary disable exit on error to retry on non-zero exit code
|
||||
set +e
|
||||
test "$ERR_EXIT_ENABLED" = true && set +e
|
||||
http_code=$(eval $COMMAND)
|
||||
exit_code=$?
|
||||
set -e
|
||||
test "$ERR_EXIT_ENABLED" = true && set -e
|
||||
if [ $http_code -eq 200 ] && [ $exit_code -eq 0 ]; then
|
||||
echo "Download completed"
|
||||
return 0
|
||||
|
||||
@@ -26,7 +26,6 @@ echo 'pref("intl.locale.requested","en_US");' >> "/usr/lib/firefox/browser/defau
|
||||
|
||||
# Download and unpack latest release of geckodriver
|
||||
downloadUrl=$(get_github_package_download_url "mozilla/geckodriver" "test(\"linux64.tar.gz$\")")
|
||||
echo "Downloading geckodriver $downloadUrl"
|
||||
download_with_retries "$downloadUrl" "/tmp" geckodriver.tar.gz
|
||||
|
||||
GECKODRIVER_DIR="/usr/local/share/gecko_driver"
|
||||
|
||||
@@ -13,7 +13,7 @@ function InstallPyPy
|
||||
PACKAGE_URL=$1
|
||||
|
||||
PACKAGE_TAR_NAME=$(echo $PACKAGE_URL | awk -F/ '{print $NF}')
|
||||
echo "Downloading tar archive '$PACKAGE_TAR_NAME' - '$PACKAGE_URL'"
|
||||
echo "Downloading tar archive '$PACKAGE_TAR_NAME'"
|
||||
PACKAGE_TAR_TEMP_PATH="/tmp/$PACKAGE_TAR_NAME"
|
||||
download_with_retries $PACKAGE_URL "/tmp" $PACKAGE_TAR_NAME
|
||||
|
||||
|
||||
Reference in New Issue
Block a user