Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Commit

Permalink
new workflow (#148)
Browse files Browse the repository at this point in the history
Conflicts:
	Jenkinsfile
  • Loading branch information
zguennoune02 authored and tuntoja committed Sep 28, 2021
1 parent 8c19f02 commit 9a948eb
Showing 1 changed file with 58 additions and 25 deletions.
83 changes: 58 additions & 25 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,105 @@
*/
def serie = '21.04'
def maintenanceBranch = "${serie}.x"
def qaBranch = "dev-${serie}.x"
env.REF_BRANCH = 'master'
env.PROJECT='centreon-gorgone'
if (env.BRANCH_NAME.startsWith('release-')) {
env.BUILD = 'RELEASE'
} else if ((env.BRANCH_NAME == 'master') || (env.BRANCH_NAME == maintenanceBranch)) {
} else if ((env.BRANCH_NAME == env.REF_BRANCH) || (env.BRANCH_NAME == maintenanceBranch)) {
env.BUILD = 'REFERENCE'
} else if ((env.BRANCH_NAME == 'develop') || (env.BRANCH_NAME == qaBranch)) {
env.BUILD = 'QA'
} else {
env.BUILD = 'CI'
}

def buildBranch = env.BRANCH_NAME
if (env.CHANGE_BRANCH) {
buildBranch = env.CHANGE_BRANCH
}

/*
** Functions
*/
def isStableBuild() {
return ((env.BUILD == 'REFERENCE') || (env.BUILD == 'QA'))
}

def checkoutCentreonBuild(buildBranch) {
def getCentreonBuildGitConfiguration = { branchName -> [
$class: 'GitSCM',
branches: [[name: "refs/heads/${branchName}"]],
doGenerateSubmoduleConfigurations: false,
userRemoteConfigs: [[
$class: 'UserRemoteConfig',
url: "ssh://git@github.com/centreon/centreon-build.git"
]]
]}

dir('centreon-build') {
try {
checkout(getCentreonBuildGitConfiguration(buildBranch))
} catch(e) {
echo "branch '${buildBranch}' does not exist in centreon-build, then fallback to master"
checkout(getCentreonBuildGitConfiguration('master'))
}
}
}
/*
** Pipeline code.
*/
stage('Source') {
stage('Deliver sources // Sonar analysis') {
node {
sh 'setup_centreon_build.sh'
checkoutCentreonBuild(buildBranch)
dir('centreon-gorgone') {
checkout scm
}
sh "./centreon-build/jobs/gorgone/${serie}/gorgone-source.sh"
source = readProperties file: 'source.properties'
env.VERSION = "${source.VERSION}"
env.RELEASE = "${source.RELEASE}"
// Run sonarQube analysis
withSonarQubeEnv('SonarQubeDev') {
sh "./centreon-build/jobs/gorgone/${serie}/gorgone-analysis.sh"
}
}
}

try {
// sonarQube step to get qualityGate result
stage('Quality gate') {
timeout(time: 10, unit: 'MINUTES') {
def qualityGate = waitForQualityGate()
if (qualityGate.status != 'OK') {
currentBuild.result = 'FAIL'
}
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Quality gate failure: ${qualityGate.status}.');
def qualityGate = waitForQualityGate()
if (qualityGate.status != 'OK') {
currentBuild.result = 'FAIL'
}
}
}

stage('Package') {
parallel 'centos7': {
try {
stage('RPM Packaging') {
parallel 'Packaging centos7': {
node {
sh 'setup_centreon_build.sh'
checkoutCentreonBuild(buildBranch)
sh "./centreon-build/jobs/gorgone/${serie}/gorgone-package.sh centos7"
archiveArtifacts artifacts: 'rpms-centos7.tar.gz'
stash name: "rpms-centos7", includes: 'output/noarch/*.rpm'
sh 'rm -rf output'
}
},
'centos8': {
'Packaging centos8': {
node {
sh 'setup_centreon_build.sh'
checkoutCentreonBuild(buildBranch)
sh "./centreon-build/jobs/gorgone/${serie}/gorgone-package.sh centos8"
archiveArtifacts artifacts: 'rpms-centos8.tar.gz'
stash name: "rpms-centos8", includes: 'output/noarch/*.rpm'
sh 'rm -rf output'
}
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Package stage failure.');
}
}

if ((env.BUILD == 'RELEASE') || (env.BUILD == 'REFERENCE')) {
if ((env.BUILD == 'RELEASE') || (env.BUILD == 'QA') || (env.BUILD == 'CI')) {
stage('Delivery') {
node {
sh 'setup_centreon_build.sh'
checkoutCentreonBuild(buildBranch)
unstash 'rpms-centos8'
unstash 'rpms-centos7'
sh "./centreon-build/jobs/gorgone/${serie}/gorgone-delivery.sh"
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
Expand Down

0 comments on commit 9a948eb

Please sign in to comment.