Commit b8f58c5f authored by Raphael Defosseux's avatar Raphael Defosseux

CI: pipeline workaround for GitLab 'cancelled' status notification when failure

See https://github.com/jenkinsci/pipeline-build-step-plugin/blob/master/CHANGELOG.md#210 for more details
Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parent bc864d13
...@@ -733,48 +733,50 @@ OAI CI Team''', ...@@ -733,48 +733,50 @@ OAI CI Team''',
// ---- Slave Job functions // ---- Slave Job functions
def triggerSlaveJob (jobName, gitlabStatusName) { def triggerSlaveJob (jobName, gitlabStatusName) {
if ("MERGE".equals(env.gitlabActionType)) { // Workaround for the "cancelled" GitLab pipeline notification
gitlabCommitStatus(name: gitlabStatusName) { // The slave job is triggered with the propagate false so the following commands are executed
build job: jobName, // Its status is now PASS/SUCCESS from a stage pipeline point of view
// localStatus variable MUST be analyzed to properly assess the status
localStatus = build job: jobName,
parameters: [ parameters: [
string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)), string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)),
string(name: 'eNB_Branch', value: String.valueOf(env.gitlabSourceBranch)), string(name: 'eNB_Branch', value: String.valueOf(env.gitlabSourceBranch)),
string(name: 'eNB_CommitID', value: String.valueOf(env.gitlabMergeRequestLastCommit)), string(name: 'eNB_CommitID', value: String.valueOf(env.gitlabMergeRequestLastCommit)),
booleanParam(name: 'eNB_mergeRequest', value: true), booleanParam(name: 'eNB_mergeRequest', value: "MERGE".equals(env.gitlabActionType)),
string(name: 'eNB_TargetBranch', value: String.valueOf(env.gitlabTargetBranch)) string(name: 'eNB_TargetBranch', value: String.valueOf(env.gitlabTargetBranch))
] ], propagate: false
} localResult = localStatus.getResult()
} else { echo "${jobName} Slave Job status is ${localResult}"
gitlabCommitStatus(name: gitlabStatusName) { gitlabCommitStatus(name: gitlabStatusName) {
build job: jobName, if (localStatus.resultIsBetterOrEqualTo('SUCCESS')) {
parameters: [ echo "${jobName} Slave Job is OK"
string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)), } else {
string(name: 'eNB_Branch', value: String.valueOf(GIT_BRANCH)), echo "${jobName} Slave Job is KO"
string(name: 'eNB_CommitID', value: String.valueOf(GIT_COMMIT)), sh "ci-scripts/fail.sh"
booleanParam(name: 'eNB_mergeRequest', value: false)
]
} }
} }
} }
def triggerSlaveJobNoGitLab (jobName) { def triggerSlaveJobNoGitLab (jobName) {
if ("MERGE".equals(env.gitlabActionType)) { // Workaround for the "cancelled" GitLab pipeline notification
build job: jobName, // The slave job is triggered with the propagate false so the following commands are executed
// Its status is now PASS/SUCCESS from a stage pipeline point of view
// localStatus variable MUST be analyzed to properly assess the status
localStatus = build job: jobName,
parameters: [ parameters: [
string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)), string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)),
string(name: 'eNB_Branch', value: String.valueOf(env.gitlabSourceBranch)), string(name: 'eNB_Branch', value: String.valueOf(env.gitlabSourceBranch)),
string(name: 'eNB_CommitID', value: String.valueOf(env.gitlabMergeRequestLastCommit)), string(name: 'eNB_CommitID', value: String.valueOf(env.gitlabMergeRequestLastCommit)),
booleanParam(name: 'eNB_mergeRequest', value: true), booleanParam(name: 'eNB_mergeRequest', value: "MERGE".equals(env.gitlabActionType)),
string(name: 'eNB_TargetBranch', value: String.valueOf(env.gitlabTargetBranch)) string(name: 'eNB_TargetBranch', value: String.valueOf(env.gitlabTargetBranch))
] ], propagate: false
localResult = localStatus.getResult()
echo "${jobName} Slave Job status is ${localResult}"
if (localStatus.resultIsBetterOrEqualTo('SUCCESS')) {
echo "${jobName} Slave Job is OK"
} else { } else {
build job: jobName, echo "${jobName} Slave Job is KO"
parameters: [ sh "ci-scripts/fail.sh"
string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)),
string(name: 'eNB_Branch', value: String.valueOf(GIT_BRANCH)),
string(name: 'eNB_CommitID', value: String.valueOf(GIT_COMMIT)),
booleanParam(name: 'eNB_mergeRequest', value: false)
]
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment