Commit 44f95998 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 fa17bd52
...@@ -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
parameters: [ // localStatus variable MUST be analyzed to properly assess the status
string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)), localStatus = build job: jobName,
string(name: 'eNB_Branch', value: String.valueOf(env.gitlabSourceBranch)), parameters: [
string(name: 'eNB_CommitID', value: String.valueOf(env.gitlabMergeRequestLastCommit)), string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)),
booleanParam(name: 'eNB_mergeRequest', value: true), string(name: 'eNB_Branch', value: String.valueOf(env.gitlabSourceBranch)),
string(name: 'eNB_TargetBranch', value: String.valueOf(env.gitlabTargetBranch)) string(name: 'eNB_CommitID', value: String.valueOf(env.gitlabMergeRequestLastCommit)),
] booleanParam(name: 'eNB_mergeRequest', value: "MERGE".equals(env.gitlabActionType)),
string(name: 'eNB_TargetBranch', value: String.valueOf(env.gitlabTargetBranch))
], propagate: false
localResult = localStatus.getResult()
echo "${jobName} Slave Job status is ${localResult}"
gitlabCommitStatus(name: gitlabStatusName) {
if (localStatus.resultIsBetterOrEqualTo('SUCCESS')) {
echo "${jobName} Slave Job is OK"
} else {
echo "${jobName} Slave Job is KO"
sh "ci-scripts/fail.sh"
} }
} else {
gitlabCommitStatus(name: gitlabStatusName) {
build job: jobName,
parameters: [
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)
]
}
} }
} }
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
parameters: [ // Its status is now PASS/SUCCESS from a stage pipeline point of view
string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)), // localStatus variable MUST be analyzed to properly assess the status
string(name: 'eNB_Branch', value: String.valueOf(env.gitlabSourceBranch)), localStatus = build job: jobName,
string(name: 'eNB_CommitID', value: String.valueOf(env.gitlabMergeRequestLastCommit)), parameters: [
booleanParam(name: 'eNB_mergeRequest', value: true), string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)),
string(name: 'eNB_TargetBranch', value: String.valueOf(env.gitlabTargetBranch)) string(name: 'eNB_Branch', value: String.valueOf(env.gitlabSourceBranch)),
] string(name: 'eNB_CommitID', value: String.valueOf(env.gitlabMergeRequestLastCommit)),
booleanParam(name: 'eNB_mergeRequest', value: "MERGE".equals(env.gitlabActionType)),
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