From 5f19f89b2f3a7c25b3aa2c8d713443767fef8090 Mon Sep 17 00:00:00 2001 From: Artsiom Siamashka Date: Sat, 27 Sep 2025 10:51:37 +0200 Subject: [PATCH] Removed env param and replaced with mapping function --- Jenkinsfile | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 960b65e..2e25405 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,16 @@ @Library('utils') _ +def mapBranchNameToWPEnv(branchName) { + def envMap = [ + master: 'new_prod', + main: 'new_prod', + develop: 'dev', + qa: 'qa', + demo: 'demo' + ] + return envMap.get(branchName, 'development') +} + pipeline { agent any @@ -7,23 +18,16 @@ pipeline { withFolderProperties() } - parameters { - choice( - name: 'ENVIRONMENT', - choices: ['dev', 'qa', 'new_prod', 'demo'], - description: 'Environment Name for the application (e.g., dev, production etc.)' - ) - } - environment { // LC_IMG_TAG = "${utils.mapBranchToEnv(env.BRANCH_NAME)}" LC_IMG_TAG = 'qa_test' + WP_ENV = "${mapBranchNameToWPEnv(env.BRANCH_NAME)}" } stages { stage('Build') { steps { - sh "docker build --build-arg ENV_NAME=${params.ENVIRONMENT} -t ${env.PUSH_REGISTRY}/${env.LC_WP_IMG}:${LC_IMG_TAG} ." + sh "docker build --build-arg ENV_NAME=${WP_ENV} -t ${env.PUSH_REGISTRY}/${env.LC_WP_IMG}:${LC_IMG_TAG} ." sh "docker push ${env.PUSH_REGISTRY}/${env.LC_WP_IMG}:${LC_IMG_TAG}" } }