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-02-28 10:56:58 +00:00
|
|
|
if (env.TARGET_PLATFORM == '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-02-28 10:56:58 +00:00
|
|
|
platform: env.TARGET_PLATFORM + (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()
|
|
|
|
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/${utils.changeId()}'
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this
|