move gh notification to post, add check for CHANGE_ID

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-01-09 11:53:59 +01:00
parent b56fd2e29f
commit cc542969c0
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
6 changed files with 13 additions and 30 deletions

View File

@ -92,11 +92,6 @@ pipeline {
}
}
}
stage('Notify') {
steps {
script { cmn.notifyPRSuccess() }
}
}
stage('Cleanup') {
steps {
script { cmn.clean() }
@ -105,5 +100,6 @@ pipeline {
}
post {
failure { script { load('ci/common.groovy').notifyPRFailure() } }
success { script { load('ci/common.groovy').notifyPRSuccess() } }
}
}

View File

@ -86,11 +86,6 @@ pipeline {
}
}
}
stage('Notify') {
steps {
script { cmn.notifyPRSuccess() }
}
}
stage('Cleanup') {
steps {
script { cmn.clean() }
@ -99,5 +94,6 @@ pipeline {
}
post {
failure { script { load('ci/common.groovy').notifyPRFailure() } }
success { script { load('ci/common.groovy').notifyPRSuccess() } }
}
}

View File

@ -99,11 +99,6 @@ pipeline {
script { env.PKG_URL = cmn.uploadArtifact(app) }
}
}
stage('Notify') {
steps {
script { cmn.notifyPRSuccess() }
}
}
stage('Cleanup') {
steps {
script { cmn.clean() }
@ -112,5 +107,6 @@ pipeline {
}
post {
failure { script { load('ci/common.groovy').notifyPRFailure() } }
success { script { load('ci/common.groovy').notifyPRSuccess() } }
}
}

View File

@ -80,11 +80,6 @@ pipeline {
script { env.PKG_URL = cmn.uploadArtifact(dmg) }
}
}
stage('Notify') {
steps {
script { cmn.notifyPRSuccess() }
}
}
stage('Cleanup') {
steps {
script { cmn.clean() }
@ -93,5 +88,6 @@ pipeline {
}
post {
failure { script { load('ci/common.groovy').notifyPRFailure() } }
success { script { load('ci/common.groovy').notifyPRSuccess() } }
}
}

View File

@ -102,11 +102,6 @@ pipeline {
script { env.PKG_URL = cmn.uploadArtifact(app) }
}
}
stage('Notify') {
steps {
script { cmn.notifyPRSuccess() }
}
}
stage('Cleanup') {
steps {
script { cmn.clean() }
@ -115,5 +110,6 @@ pipeline {
}
post {
failure { script { load('ci/common.groovy').notifyPRFailure() } }
success { script { load('ci/common.groovy').notifyPRSuccess() } }
}
}

View File

@ -152,6 +152,11 @@ def changeId() {
def changeId = env.CHANGE_ID
changeId = params.CHANGE_ID ? params.CHANGE_ID : changeId
changeId = getParentRunEnv('CHANGE_ID') ? getParentRunEnv('CHANGE_ID') : changeId
if (!changeId) {
println('This build is not related to a PR, CHANGE_ID missing.')
println('GitHub notification impossible, skipping...')
return null
}
return changeId
}
@ -194,11 +199,7 @@ def ghcmgrPostBuild(success) {
def gitHubNotify(message) {
def githubIssuesUrl = 'https://api.github.com/repos/status-im/status-react/issues'
def changeId = changeId()
if (!changeId) { /* CHANGE_ID exists only when run as a PR build */
println('This build is not related to a PR, CHANGE_ID missing.')
println('GitHub notification impossible, skipping...')
return
}
if (changeId == null) { return }
def msgObj = [body: message]
def msgJson = new JsonBuilder(msgObj).toPrettyString()
withCredentials([usernamePassword(
@ -255,6 +256,7 @@ def gitHubNotifyPRSuccess() {
}
def notifyPRFailure() {
if (changeId() == null) { return }
try {
ghcmgrPostBuild(false)
} catch (ex) { /* fallback to posting directly to GitHub */
@ -264,6 +266,7 @@ def notifyPRFailure() {
}
def notifyPRSuccess() {
if (changeId() == null) { return }
try {
ghcmgrPostBuild(true)
} catch (ex) { /* fallback to posting directly to GitHub */