add retries to SauceLabs upload

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-03-07 10:19:24 +01:00
parent ba37f7b8d0
commit 3253f0d847
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
1 changed files with 12 additions and 2 deletions

View File

@ -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