diff --git a/ci/Jenkinsfile.android b/ci/Jenkinsfile.android index 8a2b98a2a2..f412642d76 100644 --- a/ci/Jenkinsfile.android +++ b/ci/Jenkinsfile.android @@ -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() } } } } diff --git a/ci/Jenkinsfile.ios b/ci/Jenkinsfile.ios index fa153c08d8..05c19c5e71 100644 --- a/ci/Jenkinsfile.ios +++ b/ci/Jenkinsfile.ios @@ -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() } } } } diff --git a/ci/Jenkinsfile.linux b/ci/Jenkinsfile.linux index 513e8cc265..6311ee6a03 100644 --- a/ci/Jenkinsfile.linux +++ b/ci/Jenkinsfile.linux @@ -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() } } } } diff --git a/ci/Jenkinsfile.macos b/ci/Jenkinsfile.macos index da88ecbcf1..686bceddab 100644 --- a/ci/Jenkinsfile.macos +++ b/ci/Jenkinsfile.macos @@ -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() } } } } diff --git a/ci/Jenkinsfile.windows b/ci/Jenkinsfile.windows index ca3ef119f3..cd79f233e5 100644 --- a/ci/Jenkinsfile.windows +++ b/ci/Jenkinsfile.windows @@ -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() } } } } diff --git a/ci/common.groovy b/ci/common.groovy index 9552a3f9e9..b707c2e871 100644 --- a/ci/common.groovy +++ b/ci/common.groovy @@ -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 */