From b3e658f9aabb6a18a5bc7058ad98f7c46a29b3ce Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 6 Feb 2024 10:20:04 +0100 Subject: [PATCH] ci: refs#6706 Jenkinsfile fixes --- Jenkinsfile | 106 +++++++++++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 47 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bd19e8e15..28c5e4775 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,34 +5,36 @@ def FROM_GIT def RUN_TESTS def RUN_BUILD -pre: { - switch (env.BRANCH_NAME) { - case 'test': - env.NODE_ENV = 'test' - env.BACK_REPLICAS = 2 - break - case 'master': - env.NODE_ENV = 'production' - env.BACK_REPLICAS = 4 - break - default: - env.NODE_ENV = 'dev' - env.BACK_REPLICAS = 1 +node { + stage('Setup') { + switch (env.BRANCH_NAME) { + case 'test': + env.NODE_ENV = 'test' + env.BACK_REPLICAS = 2 + break + case 'master': + env.NODE_ENV = 'production' + env.BACK_REPLICAS = 4 + break + default: + env.NODE_ENV = 'dev' + env.BACK_REPLICAS = 1 + } + + PROTECTED_BRANCH = [ + 'dev', + 'test', + 'master' + ].contains(env.BRANCH_NAME) + + FROM_GIT = env.JOB_NAME.startsWith('gitea/') + RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT + RUN_BUILD = PROTECTED_BRANCH && FROM_GIT + + // Uncomment to enable debugging + // https://loopback.io/doc/en/lb3/Setting-debug-strings.html#debug-strings-reference + //env.DEBUG = 'strong-remoting:shared-method' } - - PROTECTED_BRANCH = [ - 'dev', - 'test', - 'master' - ].contains(env.BRANCH_NAME) - - FROM_GIT = env.JOB_NAME.startsWith('gitea/') - RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT - RUN_BUILD = PROTECTED_BRANCH && FROM_GIT - - // Uncomment to enable debugging - // https://loopback.io/doc/en/lb3/Setting-debug-strings.html#debug-strings-reference - //env.DEBUG = 'strong-remoting:shared-method' } pipeline { agent any @@ -47,29 +49,47 @@ pipeline { STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}" } stages { + stage('Install') { + environment { + NODE_ENV = '' + } + parallel { + stage('Back') { + steps { + sh 'pnpm install --prefer-offline' + } + } + stage('Print') { + when { + expression { FROM_GIT } + } + steps { + sh 'pnpm install --prefer-offline --prefix=print' + } + } + stage('Front') { + when { + expression { FROM_GIT } + } + steps { + sh 'pnpm install --prefer-offline --prefix=front' + } + } + } + } stage('Stack') { environment { - NODE_ENV = "" TZ = 'Europe/Madrid' } parallel { stage('Back') { stages { - stage('Install') { - environment { - NODE_ENV = "" - } - steps { - sh 'pnpm install --prefer-offline' - sh 'pnpm install --prefer-offline --prefix=print' - } - } stage('Test') { when { expression { RUN_TESTS } } environment { - NODE_ENV = "" + NODE_ENV = '' } steps { sh 'npm run test:back:ci' @@ -106,20 +126,12 @@ pipeline { expression { FROM_GIT } } stages { - stage('Install') { - environment { - NODE_ENV = "" - } - steps { - sh 'pnpm install --prefer-offline --prefix=front' - } - } stage('Test') { when { expression { RUN_TESTS } } environment { - NODE_ENV = "" + NODE_ENV = '' } steps { sh 'jest --ci --reporters=default --reporters=jest-junit --maxWorkers=10'