75 lines
3.2 KiB
Plaintext
75 lines
3.2 KiB
Plaintext
// Comments
|
|
|
|
pipeline {
|
|
agent {
|
|
label 'bellatrix'
|
|
}
|
|
options {
|
|
disableConcurrentBuilds()
|
|
timestamps()
|
|
gitLabConnection('OAI GitLab')
|
|
//gitlabBuilds(builds: ["Build", "Test"])
|
|
}
|
|
|
|
stages {
|
|
stage ("Verify Parameters") {
|
|
steps {
|
|
echo 'Verify Parameters'
|
|
echo "Git URL is ${GIT_URL}"
|
|
echo "GitLab Act is ${env.gitlabActionType}"
|
|
script {
|
|
if ("MERGE".equals(env.gitlabActionType)) {
|
|
// GitLab-Jenkins pugin integration is lacking to perform the merge by itself
|
|
// Doing it manually --> it may have merge conflicts
|
|
sh "./ci-scripts/doGitLabMerge.sh ${env.gitlabSourceBranch} ${env.gitlabMergeRequestLastCommit} ${env.gitlabTargetBranch} ${GIT_COMMIT}"
|
|
sh "./ci-scripts/checkCodingFormattingRules.sh ${env.gitlabSourceBranch} ${env.gitlabTargetBranch}"
|
|
def res=readFile('./oai_rules_result.txt').trim();
|
|
if ("0".equals(res)) {
|
|
addGitLabMRComment comment: "All Changed files in Merge Request follow OAI Formatting Rules"
|
|
} else {
|
|
addGitLabMRComment comment: "Some Changed files in Merge Request DO NOT follow OAI Formatting Rules"
|
|
}
|
|
} else {
|
|
echo "Git Branch is ${GIT_BRANCH}"
|
|
echo "Git Commit is ${GIT_COMMIT}"
|
|
sh "./ci-scripts/checkCodingFormattingRules.sh"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
always {
|
|
script {
|
|
echo "End of script"
|
|
}
|
|
}
|
|
success {
|
|
script {
|
|
def message = "OAI build #" + BUILD_ID + " passed (" + BUILD_URL + ")"
|
|
if ("MERGE".equals(env.gitlabActionType)) {
|
|
echo "This is a MERGE event"
|
|
addGitLabMRComment comment: message
|
|
def message2 = "OAI build #" + BUILD_ID + " passed (" + BUILD_URL + ") -- MergeRequest #" + env.gitlabMergeRequestIid + " (" + env.gitlabMergeRequestTitle + ")"
|
|
slackSend channel: 'ci-enb', color: 'good', message: message2
|
|
} else {
|
|
slackSend channel: 'ci-enb', color: 'good', message: message
|
|
}
|
|
}
|
|
}
|
|
failure {
|
|
script {
|
|
def message = "OAI build #" + BUILD_ID + " failed (" + BUILD_URL + ")"
|
|
if ("MERGE".equals(env.gitlabActionType)) {
|
|
echo "This is a MERGE event"
|
|
addGitLabMRComment comment: message
|
|
def message2 = "OAI build #" + BUILD_ID + " failed (" + BUILD_URL + ") -- MergeRequest #" + env.gitlabMergeRequestIid + " (" + env.gitlabMergeRequestTitle + ")"
|
|
slackSend channel: 'ci-enb', color: 'danger', message: message2
|
|
} else {
|
|
slackSend channel: 'ci-enb', color: 'danger', message: message
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|