Commit 128eca8b authored by Raphael Defosseux's avatar Raphael Defosseux

Adding notifications

Signed-off-by: Raphael Defosseux's avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parent f929758e
......@@ -5,8 +5,6 @@ pipeline {
label 'bellatrix'
}
options {
gitLabConnection('OAI GitLab')
gitlabCommitStatus(name: 'OAI jenkins')
disableConcurrentBuilds()
timestamps()
}
......@@ -19,6 +17,20 @@ pipeline {
echo "Git Branch is ${GIT_BRANCH}"
echo "Git Commit is ${GIT_COMMIT}"
echo "Git URL is ${GIT_URL}"
echo "GitLab Act is ${env.gitlabActionType}"
script {
if ("MERGE".equals(env.gitlabActionType)) {
echo "GitLab src branch is ${env.gitlabSourceBranch}"
echo "GitLab tar branch is ${env.gitlabTargetBranch}"
// GitLab-Jenkins pugin integration is lacking to perform the merge by itself
// Doing it manually --> it may have merge conflicts
sh "git merge --ff origin/${env.gitlabTargetBranch}"
sh "git log -n1"
} else {
def message = "OAI build #" + BUILD_ID
updateGitlabCommitStatus name: message, state: 'pending'
}
}
}
}
stage ('Build') {
......@@ -42,10 +54,35 @@ pipeline {
}
}
success {
updateGitlabCommitStatus name: 'OAI jenkins', state: 'success'
script {
if ("MERGE".equals(env.gitlabActionType)) {
echo "This is a MERGE event"
def msg = "OAI build #" + BUILD_ID + " passed"
echo "$msg"
addGitLabMRComment comment: msg
def message = "OAI build #" + BUILD_ID + " passed (" + BUILD_URL + ")"
echo "$message"
addGitLabMRComment comment: message
} else {
echo "This is a PUSH event"
def message = "OAI build #" + BUILD_ID
echo "$message"
updateGitlabCommitStatus name: message, state: 'success'
}
}
}
failure {
updateGitlabCommitStatus name: 'OAI jenkins', state: 'failed'
script {
if ("MERGE".equals(env.gitlabActionType)) {
echo "This is a MERGE event"
def message = "OAI build #" + BUILD_ID + " failed (" + BUILD_URL + ")"
addGitLabMRComment comment: message
} else {
echo "This is a PUSH event"
def message = "OAI build #" + BUILD_ID
updateGitlabCommitStatus name: message, state: 'failed'
}
}
}
}
}
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