From d407aeb4ad65a38911b29120636b259cc1f18029 Mon Sep 17 00:00:00 2001 From: Semab-Tariq Date: Thu, 27 May 2021 17:24:21 +0500 Subject: [PATCH] [PPS-141] Add Notarization related code inside for loop to avoid daily builds failures --- resources/notarize_apps.sh | 49 +++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/resources/notarize_apps.sh b/resources/notarize_apps.sh index d8a4bf30f..6d1a3f2d7 100755 --- a/resources/notarize_apps.sh +++ b/resources/notarize_apps.sh @@ -37,8 +37,27 @@ if [ "${package_name##*.}" = "dmg" ]; then security unlock-keychain -p $KEYCHAIN_PASSWD ~/Library/Keychains/login.keychain;codesign --verbose --verify --deep -f -i 'com.edb.postgresql' -s 'Developer ID Application: EnterpriseDB Corporation' --options runtime $package_name || _die "Failed to codesign $package_name" echo "$package_name Code signed done successfully" fi -requestUUID=$(xcrun altool --notarize-app -f $package_name --asc-provider $dev_asc_provider --primary-bundle-id $dev_primary_bundle_id -u $dev_account -p "@keychain:${dev_password_keychain_name}" 2>&1 | awk '/RequestUUID/ { print $NF; }') +cmd_status=0 +for i in {1..3}; do + echo "Trying attempt ($i/3) to upload/notarize $package_name file .. " + notarize_app=$(xcrun altool --notarize-app -f $package_name --asc-provider $dev_asc_provider --primary-bundle-id $dev_primary_bundle_id -u $dev_account -p "@keychain:${dev_password_keychain_name}" 2>&1 | awk '/RequestUUID/ { print $NF; }') + if [ $cmd_status != 0 ]; then + # Due to network latency or any other network issue if it fails + # then we need to retry at least 3 times + # notarize_app will contain error details + echo "## $notarize_app" + else + # No need to retry again - it is sucessfully uploaded + break; + fi +done +# print error if above command fails +if [ $cmd_status != 0 ]; then + echo "## could not upload for notarization" + exit 1 +fi +requestUUID=$notarize_app if [[ $requestUUID == "" ]]; then echo "ERROR:could not upload for notarization" exit 1 @@ -46,15 +65,27 @@ fi echo "Notarization RequestUUID: $requestUUID" -# wait for status to be not "in progress" any more -request_status="in progress" -while [[ "$request_status" == "in progress" ]]; do - echo "waiting... " - sleep 30 - request_status=$(requeststatus "$requestUUID") - echo "request_status = $request_status" -done +# some time request_status gets empty status in between while fatching notarization-info +# so we need to atleast try 10 time to avoid daily build failure +# if everything is successful then we can break the loop +for i in {1..10}; do + echo "Trying attempt ($i/10) to get notarize information .. " + # wait for status to be not "in progress" any more + request_status="in progress" + while [[ "$request_status" == "in progress" ]]; do + echo "waiting... " + sleep 30 + request_status=$(requeststatus "$requestUUID") + echo "request_status = $request_status" + done + + # exit the loop if return status is success + if [[ $request_status == "success" ]]; then + break + fi + +done # print status information xcrun altool --notarization-info $requestUUID \ --username $dev_account \