diff --git a/Jenkinsfile b/Jenkinsfile index 261e45bf9..cff972fa6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,30 +2,46 @@ def PROTECTED_BRANCH -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 +def BRANCH_ENV = [ + test: 'test', + master: 'production' +] + +node { + stage('Setup') { + env.BACK_REPLICAS = 1 + env.NODE_ENV = BRANCH_ENV[env.BRANCH_NAME] ?: 'dev' + + PROTECTED_BRANCH = [ + 'dev', + 'test', + 'master' + ].contains(env.BRANCH_NAME) + + // https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables + echo "NODE_NAME: ${env.NODE_NAME}" + echo "WORKSPACE: ${env.WORKSPACE}" + + configFileProvider([ + configFile(fileId: 'salix-front.properties', + variable: 'PROPS_FILE') + ]) { + def props = readProperties file: PROPS_FILE + props.each {key, value -> env."${key}" = value } + props.each {key, value -> echo "${key}: ${value}" } + } + + if (PROTECTED_BRANCH) { + configFileProvider([ + configFile(fileId: "salix-front.branch.${env.BRANCH_NAME}", + variable: 'BRANCH_PROPS_FILE') + ]) { + def props = readProperties file: BRANCH_PROPS_FILE + props.each {key, value -> env."${key}" = value } + props.each {key, value -> echo "${key}: ${value}" } + } + } } - - PROTECTED_BRANCH = [ - 'dev', - 'test', - 'master' - ].contains(env.BRANCH_NAME) - - // Uncomment to enable debugging - // https://loopback.io/doc/en/lb3/Setting-debug-strings.html#debug-strings-reference - //env.DEBUG = 'strong-remoting:shared-method' } pipeline {