2019-02-05 09:35:14 +00:00
|
|
|
import groovy.json.JsonBuilder
|
|
|
|
|
|
|
|
utils = load 'ci/utils.groovy'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Methods for interacting with ghcmgr API.
|
|
|
|
* For more details see:
|
|
|
|
* https://github.com/status-im/github-comment-manager
|
|
|
|
**/
|
|
|
|
|
|
|
|
def buildObj(success) {
|
2019-03-08 10:32:15 +00:00
|
|
|
def pkg_url = env.PKG_URL
|
|
|
|
/* a bare ipa file is not installable on iOS */
|
2019-11-29 10:20:08 +00:00
|
|
|
if (env.TARGET == 'ios') {
|
2019-03-08 10:32:15 +00:00
|
|
|
pkg_url = env.DIAWI_URL
|
|
|
|
}
|
2019-02-05 09:35:14 +00:00
|
|
|
/* assemble build object valid for ghcmgr */
|
|
|
|
return [
|
|
|
|
id: env.BUILD_DISPLAY_NAME,
|
|
|
|
commit: GIT_COMMIT.take(8),
|
|
|
|
success: success != null ? success : true,
|
2019-11-29 10:20:08 +00:00
|
|
|
platform: env.TARGET + (utils.getBuildType() == 'e2e' ? '-e2e' : ''),
|
2019-02-05 09:35:14 +00:00
|
|
|
duration: utils.buildDuration(),
|
|
|
|
url: currentBuild.absoluteUrl,
|
2019-03-08 10:32:15 +00:00
|
|
|
pkg_url: pkg_url,
|
2019-02-05 09:35:14 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
def postBuild(success) {
|
|
|
|
/**
|
|
|
|
* This is our own service for avoiding comment spam.
|
|
|
|
* https://github.com/status-im/github-comment-manager
|
|
|
|
**/
|
|
|
|
def ghcmgrurl = 'https://ghcmgr.status.im'
|
|
|
|
def body = buildObj(success)
|
|
|
|
def json = new JsonBuilder(body).toPrettyString()
|
2019-04-24 14:30:37 +00:00
|
|
|
def stdout = null
|
2019-02-05 09:35:14 +00:00
|
|
|
withCredentials([usernamePassword(
|
|
|
|
credentialsId: 'ghcmgr-auth',
|
|
|
|
usernameVariable: 'GHCMGR_USER',
|
|
|
|
passwordVariable: 'GHCMGR_PASS'
|
|
|
|
)]) {
|
2019-04-24 14:30:37 +00:00
|
|
|
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')) {
|
|
|
|
println("STDOUT:\n${stdout}")
|
2019-10-01 09:51:48 +00:00
|
|
|
error("Notifying GHCMGR failed")
|
2019-02-05 09:35:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this
|