From aba88c812e7b4c70e7c41396ebe9a17ad445584b Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 1 Feb 2024 21:35:28 +0100 Subject: [PATCH] build: refs #6706 Jenkinsfile globals --- Jenkinsfile | 53 +++++++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e6235f0eb..74fd68f09 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,8 +1,28 @@ #!/usr/bin/env groovy -def PROTECTED_BRANCH -def FROM_GIT -def RUN_TESTS +switch (env.BRANCH_NAME) { + case 'dev': + env.NODE_ENV = 'dev' + env.BACK_REPLICAS = 1 + break + case 'test': + env.NODE_ENV = 'test' + env.BACK_REPLICAS = 2 + break + case 'master': + env.NODE_ENV = 'production' + env.BACK_REPLICAS = 4 + break +} + +def PROTECTED_BRANCH = [ + 'dev', + 'test', + 'master' +].contains(env.BRANCH_NAME) + +def FROM_GIT = env.JOB_NAME.startsWith('gitea/') +def RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT pipeline { agent any @@ -21,22 +41,8 @@ pipeline { steps { script { // Uncomment to enable debugging - //env.DEBUG = 'strong-remoting:http-context,strong-remoting:shared-method' - - switch (env.BRANCH_NAME) { - case 'dev': - env.NODE_ENV = 'dev' - env.BACK_REPLICAS = 1 - break - case 'test': - env.NODE_ENV = 'test' - env.BACK_REPLICAS = 2 - break - case 'master': - env.NODE_ENV = 'production' - env.BACK_REPLICAS = 4 - break - } + // https://loopback.io/doc/en/lb3/Setting-debug-strings.html#debug-strings-reference + //env.DEBUG = 'strong-remoting:shared-method' def packageJson = readJSON file: 'package.json' env.VERSION = packageJson.version @@ -45,15 +51,6 @@ pipeline { script: 'git log -1 --pretty=%B ${GIT_COMMIT}', returnStdout: true ).trim() - - PROTECTED_BRANCH = [ - 'dev', - 'test', - 'master' - ].contains(env.BRANCH_NAME) - - FROM_GIT = JOB_NAME.startsWith('gitea/') - RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT } setEnv() }