Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
remove duplication (#10339)
Browse files Browse the repository at this point in the history
  • Loading branch information
zguennoune02 committed Oct 20, 2021
1 parent 250f98b commit 451f873
Showing 1 changed file with 83 additions and 157 deletions.
240 changes: 83 additions & 157 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@ env.REF_BRANCH = 'master'
env.PROJECT='centreon-web'
if (env.BRANCH_NAME.startsWith('release-')) {
env.BUILD = 'RELEASE'
env.DELIVERY_STAGE = 'Delivery to testing'
env.DOCKER_STAGE = 'Docker packaging'
} else if ((env.BRANCH_NAME == env.REF_BRANCH) || (env.BRANCH_NAME == maintenanceBranch)) {
env.BUILD = 'REFERENCE'
env.DELIVERY_STAGE = 'Delivery to canary'
env.DOCKER_STAGE = 'Docker packaging with canary rpms'
} else if ((env.BRANCH_NAME == 'develop') || (env.BRANCH_NAME == qaBranch)) {
env.BUILD = 'QA'
env.DELIVERY_STAGE = 'Delivery to unstable'
env.DOCKER_STAGE = 'Docker packaging with unstable rpms'
} else {
env.BUILD = 'CI'
env.DELIVERY_STAGE = 'Delivery to canary'
env.DOCKER_STAGE = 'Docker packaging with canary rpms'
}

def buildBranch = env.BRANCH_NAME
Expand Down Expand Up @@ -304,189 +312,107 @@ try {
}
}

if ((env.BUILD == 'CI') || (env.BUILD == "REFERENCE")) {
stage('Delivery to canary') {
node {
checkoutCentreonBuild()
sh 'rm -rf output'
unstash 'tar-sources'
unstash 'api-doc'
unstash 'rpms-centos8'
unstash 'rpms-centos7'
sh "./centreon-build/jobs/web/${serie}/mon-web-delivery.sh"
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Delivery stage failure');
}
}
}

if ((env.BUILD == 'QA')) {
stage('Delivery to unstable') {
node {
checkoutCentreonBuild()
sh 'rm -rf output'
unstash 'tar-sources'
unstash 'api-doc'
unstash 'rpms-centos8'
unstash 'rpms-centos7'
sh "./centreon-build/jobs/web/${serie}/mon-web-delivery.sh"
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Delivery stage failure');
}
stage("$DELIVERY_STAGE") {
node {
checkoutCentreonBuild()
sh 'rm -rf output'
unstash 'tar-sources'
unstash 'api-doc'
unstash 'rpms-centos8'
unstash 'rpms-centos7'
sh "./centreon-build/jobs/web/${serie}/mon-web-delivery.sh"
}
}

if ((env.BUILD == 'RELEASE')) {
stage('Delivery to testing') {
node {
checkoutCentreonBuild()
sh 'rm -rf output'
unstash 'tar-sources'
unstash 'api-doc'
unstash 'rpms-centos8'
unstash 'rpms-centos7'
sh "./centreon-build/jobs/web/${serie}/mon-web-delivery.sh"
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Delivery stage failure');
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Delivery stage failure');
}
}

if ((env.BUILD == 'CI') || (env.BUILD == 'REFERENCE')) {
stage('Docker packaging with canary rpms') {
def parallelSteps = [:]
def osBuilds = isStableBuild() ? ['centos7', 'centos8'] : ['centos7']
for (x in osBuilds) {
def osBuild = x
parallelSteps[osBuild] = {
node {
checkoutCentreonBuild()
sh "./centreon-build/jobs/web/${serie}/mon-web-bundle.sh ${osBuild}"
}
}
}
parallel parallelSteps
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Bundle stage failure.');
}
}
}

if ((env.BUILD == 'QA')) {
stage('Docker packaging with unstable rpms') {
def parallelSteps = [:]
def osBuilds = isStableBuild() ? ['centos7', 'centos8'] : ['centos7']
for (x in osBuilds) {
def osBuild = x
parallelSteps[osBuild] = {
node {
checkoutCentreonBuild()
sh "./centreon-build/jobs/web/${serie}/mon-web-bundle.sh ${osBuild}"
}
stage("$DOCKER_STAGE") {
def parallelSteps = [:]
def osBuilds = isStableBuild() ? ['centos7', 'centos8'] : ['centos7']
for (x in osBuilds) {
def osBuild = x
parallelSteps[osBuild] = {
node {
checkoutCentreonBuild()
sh "./centreon-build/jobs/web/${serie}/mon-web-bundle.sh ${osBuild}"
}
}
parallel parallelSteps
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Bundle stage failure.');
}
}
}

if ((env.BUILD == 'RELEASE')) {
stage('Docker packaging') {
def parallelSteps = [:]
def osBuilds = isStableBuild() ? ['centos7', 'centos8'] : ['centos7']
for (x in osBuilds) {
def osBuild = x
parallelSteps[osBuild] = {
node {
checkoutCentreonBuild()
sh "./centreon-build/jobs/web/${serie}/mon-web-bundle.sh ${osBuild}"
}
}
}
parallel parallelSteps
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Bundle stage failure.');
}
parallel parallelSteps
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Bundle stage failure.');
}
}

if ((env.BUILD == 'QA') || (env.BUILD == 'CI') || (env.BUILD == 'REFERENCE')) {
stage('API // E2E') {
parallel 'API Tests': {
if (hasBackendChanges) {
def parallelSteps = [:]
for (x in apiFeatureFiles) {
def feature = x
parallelSteps[feature] = {
node {
checkoutCentreonBuild()
unstash 'tar-sources'
unstash 'vendor'
def acceptanceStatus = sh(
script: "./centreon-build/jobs/web/${serie}/mon-web-api-integration-test.sh centos7 tests/api/features/${feature}",
returnStatus: true
)
junit 'xunit-reports/**/*.xml'
if ((currentBuild.result == 'UNSTABLE') || (acceptanceStatus != 0))
currentBuild.result = 'FAILURE'
archiveArtifacts allowEmptyArchive: true, artifacts: 'api-integration-test-logs/*.txt'
}
}
}
parallel parallelSteps
}
},
'E2E tests': {
stage('API // E2E') {
parallel 'API Tests': {
if (hasBackendChanges) {
def parallelSteps = [:]
for (x in e2eFeatureFiles) {
for (x in apiFeatureFiles) {
def feature = x
parallelSteps[feature] = {
node {
checkoutCentreonBuild()
unstash 'tar-sources'
unstash 'cypress-node-modules'
timeout(time: 10, unit: 'MINUTES') {
def acceptanceStatus = sh(script: "./centreon-build/jobs/web/${serie}/mon-web-e2e-test.sh centos7 tests/e2e/cypress/integration/${feature}", returnStatus: true)
junit 'centreon-web*/tests/e2e/cypress/results/reports/junit-report.xml'
if ((currentBuild.result == 'UNSTABLE') || (acceptanceStatus != 0))
currentBuild.result = 'FAILURE'
archiveArtifacts allowEmptyArchive: true, artifacts: 'centreon-web*/tests/e2e/cypress/results/**/*.mp4, centreon-web*/tests/e2e/cypress/results/**/*.png'
}
}
}
}
parallel parallelSteps
}
}
}

if ((env.BUILD == 'RELEASE') || (env.BUILD == 'QA') || (env.BUILD == 'REFERENCE')) {
stage('Acceptance tests') {
if (hasBackendChanges || hasFrontendChanges) {
def atparallelSteps = [:]
for (x in featureFiles) {
def feature = x
atparallelSteps[feature] = {
node {
checkoutCentreonBuild()
unstash 'tar-sources'
unstash 'vendor'
def acceptanceStatus = sh(
script: "./centreon-build/jobs/web/${serie}/mon-web-acceptance.sh centos7 features/${feature} ${acceptanceTag}",
script: "./centreon-build/jobs/web/${serie}/mon-web-api-integration-test.sh centos7 tests/api/features/${feature}",
returnStatus: true
)
junit 'xunit-reports/**/*.xml'
if ((currentBuild.result == 'UNSTABLE') || (acceptanceStatus != 0))
currentBuild.result = 'FAILURE'
archiveArtifacts allowEmptyArchive: true, artifacts: 'acceptance-logs/*.txt, acceptance-logs/*.png, acceptance-logs/*.flv'
archiveArtifacts allowEmptyArchive: true, artifacts: 'api-integration-test-logs/*.txt'
}
}
}
parallel parallelSteps
}
},
'E2E tests': {
def parallelSteps = [:]
for (x in e2eFeatureFiles) {
def feature = x
parallelSteps[feature] = {
node {
checkoutCentreonBuild()
unstash 'tar-sources'
unstash 'cypress-node-modules'
timeout(time: 10, unit: 'MINUTES') {
def acceptanceStatus = sh(script: "./centreon-build/jobs/web/${serie}/mon-web-e2e-test.sh centos7 tests/e2e/cypress/integration/${feature}", returnStatus: true)
junit 'centreon-web*/tests/e2e/cypress/results/reports/junit-report.xml'
if ((currentBuild.result == 'UNSTABLE') || (acceptanceStatus != 0))
currentBuild.result = 'FAILURE'
archiveArtifacts allowEmptyArchive: true, artifacts: 'centreon-web*/tests/e2e/cypress/results/**/*.mp4, centreon-web*/tests/e2e/cypress/results/**/*.png'
}
}
}
}
parallel parallelSteps
}
}

stage('Acceptance tests') {
if (hasBackendChanges || hasFrontendChanges) {
def atparallelSteps = [:]
for (x in featureFiles) {
def feature = x
atparallelSteps[feature] = {
node {
checkoutCentreonBuild()
unstash 'tar-sources'
unstash 'vendor'
def acceptanceStatus = sh(
script: "./centreon-build/jobs/web/${serie}/mon-web-acceptance.sh centos7 features/${feature} ${acceptanceTag}",
returnStatus: true
)
junit 'xunit-reports/**/*.xml'
if ((currentBuild.result == 'UNSTABLE') || (acceptanceStatus != 0))
currentBuild.result = 'FAILURE'
archiveArtifacts allowEmptyArchive: true, artifacts: 'acceptance-logs/*.txt, acceptance-logs/*.png, acceptance-logs/*.flv'
}
}
parallel atparallelSteps
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Critical tests stage failure');
Expand Down

0 comments on commit 451f873

Please sign in to comment.