diff --git a/android/fastlane/Fastfile b/android/fastlane/Fastfile index 599b962064..dd41888307 100644 --- a/android/fastlane/Fastfile +++ b/android/fastlane/Fastfile @@ -107,6 +107,22 @@ platform :android do browserstack_access_key: ENV["BROWSERSTACK_ACCESS_KEY"], file_path: ENV["GRADLE_APK_OUTPUT_PATH"] ) - sh("GALOY_TEST_TOKENS=$GALOY_TEST_TOKENS && GALOY_TOKEN_2=$GALOY_TOKEN_2 && MAILSLURP_API_KEY=$MAILSLURP_API_KEY && yarn test:browserstack:android") + + max_retries = 3 + retries = 0 + + begin + sh("GALOY_TOKEN_2=$GALOY_TOKEN_2 && MAILSLURP_API_KEY=$MAILSLURP_API_KEY && yarn test:browserstack:android") + rescue => e + retries += 1 + if retries < max_retries + UI.message("Error: #{e}. Retrying... (Attempt #{retries}/#{max_retries})") + retry + else + UI.error("Failed after #{max_retries} attempts. Exiting.") + raise e + end + end end + end diff --git a/ios/fastlane/Fastfile b/ios/fastlane/Fastfile index d3628c16f3..3bfcf8af4e 100644 --- a/ios/fastlane/Fastfile +++ b/ios/fastlane/Fastfile @@ -128,6 +128,21 @@ platform :ios do browserstack_username: ENV["BROWSERSTACK_USER"], browserstack_access_key: ENV["BROWSERSTACK_ACCESS_KEY"], ) - sh("GALOY_TEST_TOKENS=$GALOY_TEST_TOKENS && GALOY_TOKEN_2=$GALOY_TOKEN_2 && MAILSLURP_API_KEY=$MAILSLURP_API_KEY && yarn test:browserstack:ios") + + max_retries = 3 + retries = 0 + + begin + sh("GALOY_TOKEN_2=$GALOY_TOKEN_2 && MAILSLURP_API_KEY=$MAILSLURP_API_KEY && yarn test:browserstack:ios") + rescue => e + retries += 1 + if retries < max_retries + UI.message("Error: #{e}. Retrying... (Attempt #{retries}/#{max_retries})") + retry + else + UI.error("Failed after #{max_retries} attempts. Exiting.") + raise e + end + end end end