diff --git a/jenkins/scripts/pypi-tarball-upload.sh b/jenkins/scripts/pypi-tarball-upload.sh index ac482ee876..cbcfc232cb 100755 --- a/jenkins/scripts/pypi-tarball-upload.sh +++ b/jenkins/scripts/pypi-tarball-upload.sh @@ -34,6 +34,21 @@ curl --fail -o $FILENAME http://$TARBALL_SITE/$PROJECT/$FILENAME file -b $FILENAME | grep gzip # Uploads may claim to fail but actually succeed so we check if we -# can download after upload to determine success. -twine upload -r pypi $FILENAME || true -curl --head --silent --fail "https://pypi.python.org/simple/$PROJECT/$FILENAME" >/dev/null 2>&1 +# can download after upload to determine success. They can also fail +# intermittently, so retrying in a delayed loop helps improve +# robustness. +TRY=0 +RETVAL=255 +set +e +while [[ $TRY -lt 3 ]] && [[ $RETVAL -ne 0 ]]; do + twine upload -r pypi $FILENAME + curl --head --silent --fail \ + "https://pypi.python.org/simple/$PROJECT/$FILENAME" >/dev/null 2>&1 + RETVAL=$? + (( TRY++ )) + if [[ $TRY -lt 3 ]] && [[ $RETVAL -ne 0 ]]; then + echo "Upload failed, retrying in $TRY seconds." >&2 + sleep $TRY + fi +done +exit $RETVAL diff --git a/jenkins/scripts/pypi-wheel-upload.sh b/jenkins/scripts/pypi-wheel-upload.sh index bf1bbeb11a..572e9d9229 100755 --- a/jenkins/scripts/pypi-wheel-upload.sh +++ b/jenkins/scripts/pypi-wheel-upload.sh @@ -36,6 +36,21 @@ curl --fail -o $FILENAME http://$TARBALL_SITE/$PROJECT/$FILENAME file -b $FILENAME | grep -i zip # Uploads may claim to fail but actually succeed so we check if we -# can download after upload to determine success. -twine upload -r pypi $FILENAME || true -curl --head --silent --fail "https://pypi.python.org/simple/$PROJECT/$FILENAME" >/dev/null 2>&1 +# can download after upload to determine success. They can also fail +# intermittently, so retrying in a delayed loop helps improve +# robustness. +TRY=0 +RETVAL=255 +set +e +while [[ $TRY -lt 3 ]] && [[ $RETVAL -ne 0 ]]; do + twine upload -r pypi $FILENAME + curl --head --silent --fail \ + "https://pypi.python.org/simple/$PROJECT/$FILENAME" >/dev/null 2>&1 + RETVAL=$? + (( TRY++ )) + if [[ $TRY -lt 3 ]] && [[ $RETVAL -ne 0 ]]; then + echo "Upload failed, retrying in $TRY seconds." >&2 + sleep $TRY + fi +done +exit $RETVAL