From 3253f0d847616bb1b0666b66eb6432d2a174242a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Thu, 7 Mar 2019 10:19:24 +0100 Subject: [PATCH] add retries to SauceLabs upload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- fastlane/Fastfile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 25fc10c93a..e272311920 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -31,13 +31,23 @@ def upload_to_saucelabs(file) username = ENV["SAUCE_USERNAME"] unique_name = ENV["SAUCE_LABS_NAME"] - url = "https://saucelabs.com/rest/v1/storage/" + username + '/' + unique_name + "?overwrite=true" + url = "https://saucelabs.com/rest/v1/storage/#{username}/#{unique_name}?overwrite=true" + # retry settings + conn_timeout = "5" + upload_timeout = "60" + upload_retries = "3" upload_result = sh( "curl", "-u", username + ':' + key, "-X", "POST", "-H", "Content-Type: application/octet-stream", + # we retry few times if upload doesn't succeed in sensible time + "--connect-timeout", conn_timeout, # max time in sec. for establishing connection + "--max-time", upload_timeout, # max time in sec. for whole transfer to take + "--retry", upload_retries, # number of retries to attempt + "--retry-max-time", upload_timeout, # same as --max-time but for retries + "--retry-delay", "0", # an exponential backoff algorithm in sec. url, # this command has `status-react/fastlane` as cwd # so we need to jump outside this folder to get a file @@ -46,7 +56,7 @@ def upload_to_saucelabs(file) # fail the lane if upload fails UI.user_error!( - "failed to upload file to saucelabs: " + upload_result + "failed to upload file to saucelabs despite #{upload_retries} retries: #{upload_result}" ) unless upload_result.include? "filename" end