From f88662b1e37140669a1d164c583644e6b1d66033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=8C=AF=E5=AE=87?= <> Date: Mon, 20 Jan 2025 10:51:32 +0800 Subject: [PATCH] refactor(EnvironmentVars): streamline variable injection by removing redundant assignments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙振宇 <> --- .../src/com/freeleaps/devops/EnvironmentVars.groovy | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/first-class-pipeline/src/com/freeleaps/devops/EnvironmentVars.groovy b/first-class-pipeline/src/com/freeleaps/devops/EnvironmentVars.groovy index be0323e6..e21002aa 100644 --- a/first-class-pipeline/src/com/freeleaps/devops/EnvironmentVars.groovy +++ b/first-class-pipeline/src/com/freeleaps/devops/EnvironmentVars.groovy @@ -10,30 +10,29 @@ class EnvironmentVars { } def injectVars(Map configurations) { - steps.env.SERVICE_NAME = "${configurations.SERVICE_NAME}" - echo "SERVICE_NAME: ${steps.env.SERVICE_NAME}" if (steps.env.SERVICE_NAME == null || steps.env.SERVICE_NAME.isEmpty()) { steps.error("SERVICE_NAME is required") } + steps.env.SERVICE_NAME = configurations.SERVICE_NAME - steps.env.SERVICE_LANG = ServiceLanguage.parse("${configurations.SERVICE_LANG}") + steps.env.SERVICE_LANG = ServiceLanguage.parse(configurations.SERVICE_LANG) if (steps.env.SERVICE_LANG == ServiceLanguage.UNKNOWN) { steps.error("Unknown service language: ${configurations.SERVICE_LANG}") } - steps.env.SERVICE_GIT_REPO = "${configurations.SERVICE_GIT_REPO}" if (steps.env.SERVICE_GIT_REPO == null || steps.env.SERVICE_GIT_REPO.isEmpty()) { steps.error("SERVICE_GIT_REPO is required") } + steps.env.SERVICE_GIT_REPO = configurations.SERVICE_GIT_REPO - steps.env.SERVICE_GIT_BRANCH = "${configurations.SERVICE_GIT_BRANCH}" if (steps.env.SERVICE_GIT_BRANCH == null || steps.env.SERVICE_GIT_BRANCH.isEmpty()) { steps.error("SERVICE_GIT_BRANCH is required") } + steps.env.SERVICE_GIT_BRANCH = configurations.SERVICE_GIT_BRANCH - steps.env.ENVIRONMENT_SLUG = "${configurations.ENVIRONMENT_SLUG}" if (steps.env.ENVIRONMENT_SLUG == null || steps.env.ENVIRONMENT_SLUG.isEmpty()) { steps.error("ENVIRONMENT_SLUG is required") } + steps.env.ENVIRONMENT_SLUG = configurations.ENVIRONMENT_SLUG } } \ No newline at end of file