add diawi upload retries

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-04-24 16:30:37 +02:00
parent c4f719352e
commit 3774a0845a
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
4 changed files with 24 additions and 12 deletions

View File

@ -36,8 +36,8 @@ def notifyPR(success) {
} catch (ex) { /* fallback to posting directly to GitHub */
println "Failed to use GHCMGR: ${ex}"
switch (success) {
case true: gh.NotifyPRSuccess(); break
case false: gh.NotifyPRFailure(); break
case true: gh.notifyPRSuccess(); break
case false: gh.notifyPRFailure(); break
}
}
}

View File

@ -34,17 +34,28 @@ def postBuild(success) {
def ghcmgrurl = 'https://ghcmgr.status.im'
def body = buildObj(success)
def json = new JsonBuilder(body).toPrettyString()
def stdout = null
withCredentials([usernamePassword(
credentialsId: 'ghcmgr-auth',
usernameVariable: 'GHCMGR_USER',
passwordVariable: 'GHCMGR_PASS'
)]) {
sh """
curl --silent --verbose -XPOST --data '${json}' \
-u '${GHCMGR_USER}:${GHCMGR_PASS}' \
-H "content-type: application/json" \
'${ghcmgrurl}/builds/status-react/${utils.changeId()}'
"""
stdout = sh(
returnStdout: true,
script: """
curl --silent \
-XPOST --data '${json}' \
-u '${GHCMGR_USER}:${GHCMGR_PASS}' \
-w '\nHTTP_CODE:%{http_code}' \
-H "content-type: application/json" \
'${ghcmgrurl}/builds/status-react/${utils.changeId()}'
"""
)
}
/* We're not using --fail because it suppresses server response */
if (!stdout.contains('HTTP_CODE:201')) {
error("Notifying GHCMGR failed with: ${httpCode}")
println("STDOUT:\n${stdout}")
}
}

View File

@ -10,7 +10,7 @@ utils = load 'ci/utils.groovy'
def notify(message) {
def githubIssuesUrl = 'https://api.github.com/repos/status-im/status-react/issues'
def changeId = changeId()
def changeId = utils.changeId()
if (changeId == null) { return }
def msgObj = [body: message]
def msgJson = new JsonBuilder(msgObj).toPrettyString()

View File

@ -161,10 +161,11 @@ end
def upload_to_diawi(source)
diawi(
token: ENV["DIAWI_TOKEN"],
file: source
file: source,
last_hope_attempts_count: 3,
token: ENV["DIAWI_TOKEN"]
)
# save the URL to a file for use in CI
File.write("diawi.out", lane_context[SharedValues::UPLOADED_FILE_LINK_TO_DIAWI])
end