2025-01-17 08:25:04 +00:00
|
|
|
package com.freeleaps.devops
|
|
|
|
|
|
|
|
|
|
import com.freeleaps.devops.enums.ServiceLanguage
|
|
|
|
|
|
|
|
|
|
class EnvironmentVars {
|
|
|
|
|
def steps
|
|
|
|
|
|
|
|
|
|
EnvironmentVars(steps) {
|
|
|
|
|
this.steps = steps
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def injectVars(Map configurations) {
|
|
|
|
|
steps.env.SERVICE_NAME = "${configurations.SERVICE_NAME}"
|
2025-01-20 02:48:52 +00:00
|
|
|
echo "SERVICE_NAME: ${steps.env.SERVICE_NAME}"
|
2025-01-17 08:25:04 +00:00
|
|
|
if (steps.env.SERVICE_NAME == null || steps.env.SERVICE_NAME.isEmpty()) {
|
|
|
|
|
steps.error("SERVICE_NAME is required")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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_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.ENVIRONMENT_SLUG = "${configurations.ENVIRONMENT_SLUG}"
|
|
|
|
|
if (steps.env.ENVIRONMENT_SLUG == null || steps.env.ENVIRONMENT_SLUG.isEmpty()) {
|
|
|
|
|
steps.error("ENVIRONMENT_SLUG is required")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|