From 510047b2b4db92086983628a18d9f663a4d7226b Mon Sep 17 00:00:00 2001 From: Zakaria Guennoune <83596451+zguennoune02@users.noreply.github.com> Date: Tue, 19 Oct 2021 11:31:42 +0200 Subject: [PATCH] enh(ci): new delivery workflow (#3199) --- Jenkinsfile | 63 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index acd9ef8fa..9f1c6f8e6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,10 @@ -properties([buildDiscarder(logRotator(numToKeepStr: '50'))]) + +env.REF_BRANCH = 'master' +if ((env.BRANCH_NAME == env.REF_BRANCH)) { + env.BUILD = 'REFERENCE' +} else { + env.BUILD = 'CI' +} stage('Source') { node { @@ -14,36 +20,41 @@ stage('Source') { withSonarQubeEnv('SonarQubeDev') { sh './centreon-build/jobs/plugins/plugins-analysis.sh' } + def qualityGate = waitForQualityGate() + if (qualityGate.status != 'OK') { + currentBuild.result = 'FAIL' + } } } -try { - // sonarQube step to get qualityGate result - stage('Quality gate') { +stage('RPM Packaging') { + parallel 'all': { node { - def qualityGate = waitForQualityGate() - if (qualityGate.status != 'OK') { - currentBuild.result = 'FAIL' - } - if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') { - error("Quality gate failure: ${qualityGate.status}."); - } + sh 'setup_centreon_build.sh' + sh './centreon-build/jobs/plugins/plugins-package.sh' + archiveArtifacts artifacts: 'rpms-centos7.tar.gz' + archiveArtifacts artifacts: 'rpms-centos8.tar.gz' + stash name: "rpms-centos7", includes: 'output-centos7/noarch/*.rpm' + stash name: "rpms-centos8", includes: 'output-centos8/noarch/*.rpm' + sh 'rm -rf output' } } - - stage('Package') { - parallel 'all': { - node { - sh 'setup_centreon_build.sh' - sh './centreon-build/jobs/plugins/plugins-package.sh' - } - } - if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') { - error('Package stage failure.'); - } - } -} catch(e) { - if (env.BRANCH_NAME == 'master') { - slackSend channel: "#monitoring-metrology", color: "#F30031", message: "*FAILURE*: `CENTREON PLUGINS` <${env.BUILD_URL}|build #${env.BUILD_NUMBER}> on branch ${env.BRANCH_NAME}\n*COMMIT*: by ${source.COMMITTER}\n*INFO*: ${e}" + if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') { + error('Package stage failure.'); } } + +stage('RPM Delivery') { + parallel 'all': { + node { + sh 'setup_centreon_build.sh' + unstash 'rpms-centos7' + unstash 'rpms-centos8' + sh './centreon-build/jobs/plugins/plugins-delivery.sh' + } + } + if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') { + error('Package stage failure.'); + } +} +