From 2025facc829d55ac4bddfef9ba5683f93b723f1a Mon Sep 17 00:00:00 2001 From: Zakaria Guennoune <83596451+zguennoune02@users.noreply.github.com> Date: Mon, 30 Aug 2021 10:37:29 +0200 Subject: [PATCH] enh(ci): New packaging workflow and more // jobs (#647) * deliver only for qa and release branches * remove old import * adding CI branches as delivery branches for testing purpose * editing fixme * removing fixme * comments for testing purpose * using specific c++ nodes * stashing rpms * packaging parallelised with build * keep only ten jobs in history * fixing parallel call for packaging Conflicts: Jenkinsfile --- Jenkinsfile | 86 ++++++++++++++++++++++++----------------------------- 1 file changed, 39 insertions(+), 47 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f0cdc69a5..a80a6e0ca 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,3 @@ -import groovy.json.JsonSlurper /* ** Variables. @@ -6,10 +5,14 @@ import groovy.json.JsonSlurper properties([buildDiscarder(logRotator(numToKeepStr: '50'))]) def serie = '20.10' def maintenanceBranch = "${serie}.x" +def qaBranch = "dev-${serie}" + if (env.BRANCH_NAME.startsWith('release-')) { env.BUILD = 'RELEASE' } else if ((env.BRANCH_NAME == 'master') || (env.BRANCH_NAME == maintenanceBranch)) { env.BUILD = 'REFERENCE' +} else if ((env.BRANCH_NAME == 'develop') || (env.BRANCH_NAME == qaBranch)) { + env.BUILD = 'QA' } else { env.BUILD = 'CI' } @@ -17,8 +20,8 @@ if (env.BRANCH_NAME.startsWith('release-')) { /* ** Pipeline code. */ -stage('Source') { - node { +stage('Deliver sources') { + node("C++") { sh 'setup_centreon_build.sh' dir('centreon-broker') { checkout scm @@ -31,9 +34,9 @@ stage('Source') { } try { - stage('Unit tests') { - parallel 'centos7': { - node { + stage('Build // Unit tests // Packaging') { + parallel 'build centos7': { + node("C++") { sh 'setup_centreon_build.sh' sh "./centreon-build/jobs/broker/${serie}/mon-broker-unittest.sh centos7" step([ @@ -50,8 +53,15 @@ try { } } }, - 'centos8': { - node { + 'packaging centos7': { + node("C++") { + sh 'setup_centreon_build.sh' + sh "./centreon-build/jobs/broker/${serie}/mon-broker-package.sh centos7" + stash name: 'el7-rpms', includes: "output/x86_64/*.rpm" + } + }, + 'build centos8': { + node("C++") { sh 'setup_centreon_build.sh' sh "./centreon-build/jobs/broker/${serie}/mon-broker-unittest.sh centos8" step([ @@ -64,8 +74,15 @@ try { ]) } }, - 'debian10': { - node { + 'packaging centos8': { + node("C++") { + sh 'setup_centreon_build.sh' + sh "./centreon-build/jobs/broker/${serie}/mon-broker-package.sh centos8" + stash name: 'el8-rpms', includes: "output/x86_64/*.rpm" + } + }, + 'build debian10': { + node("C++") { sh 'setup_centreon_build.sh' sh "./centreon-build/jobs/broker/${serie}/mon-broker-unittest.sh debian10" step([ @@ -77,16 +94,21 @@ try { tools: [[$class: 'GoogleTestType', pattern: 'ut.xml']] ]) } + }, + 'packaging debian10': { + node("C++") { + sh 'setup_centreon_build.sh' + sh "./centreon-build/jobs/broker/${serie}/mon-broker-package.sh debian10" + } } if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') { - error('Unit tests stage failure.'); + error('Build // Unit tests // Packaging.'); } } // sonarQube step to get qualityGate result stage('Quality gate') { - node { - sleep 120 + node("C++") { def qualityGate = waitForQualityGate() if (qualityGate.status != 'OK') { currentBuild.result = 'FAIL' @@ -97,41 +119,11 @@ try { } } - stage('Package') { - parallel 'centos7': { - node { - sh 'setup_centreon_build.sh' - sh "./centreon-build/jobs/broker/${serie}/mon-broker-package.sh centos7" - } - }, - 'centos8': { - node { - sh 'setup_centreon_build.sh' - sh "./centreon-build/jobs/broker/${serie}/mon-broker-package.sh centos8" - } - }, - 'debian10': { - node { - sh 'setup_centreon_build.sh' - sh "./centreon-build/jobs/broker/${serie}/mon-broker-package.sh debian10" - } -/* - }, - 'debian10-armhf': { - node { - sh 'setup_centreon_build.sh' - sh "./centreon-build/jobs/broker/${serie}/mon-broker-package.sh debian10-armhf" - } -*/ - } - if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') { - error('Package stage failure.'); - } - } - - if ((env.BUILD == 'RELEASE') || (env.BUILD == 'REFERENCE')) { + if ((env.BUILD == 'RELEASE') || (env.BUILD == 'QA')) { stage('Delivery') { - node { + node("C++") { + unstash 'el7-rpms' + unstash 'el8-rpms' sh 'setup_centreon_build.sh' sh "./centreon-build/jobs/broker/${serie}/mon-broker-delivery.sh" }