From 978aebf664f71f0ba73e55482aaf82f1b81541db Mon Sep 17 00:00:00 2001 From: Laura Gorzitze Date: Tue, 18 Jun 2024 10:52:14 +0200 Subject: [PATCH] Fix distribution call when calling without setting hotfix variable --- scm-packaging/docker/build.gradle | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/scm-packaging/docker/build.gradle b/scm-packaging/docker/build.gradle index 918da0d3a5..ddccc86457 100644 --- a/scm-packaging/docker/build.gradle +++ b/scm-packaging/docker/build.gradle @@ -91,10 +91,8 @@ task setupBuilder() { task build(type: Exec) { commandLine = ["docker", "buildx", "bake", "--builder", "scm-builder", isSnapshot ? "dev": "prod"] - environment "VERSION", dockerTag - environment "COMMIT_SHA", revision - environment "IMAGE", dockerRepository - environment "IS_HOTFIX", isHotfix + + setEnvironmentForDockerBuild({ String name, Object value -> environment(name, value) }) doLast { File file = new File(project.buildDir, 'docker.tag') @@ -105,10 +103,8 @@ task build(type: Exec) { task pushImages(type: Exec) { commandLine = ["docker", "buildx", "bake", "--builder", "scm-builder", isSnapshot ? "dev": "prod", "--push"] - environment "VERSION", dockerTag - environment "COMMIT_SHA", revision - environment "IMAGE", dockerRepository - environment "IS_HOTFIX", isHotfix + + setEnvironmentForDockerBuild({ String name, Object value -> environment(name, value) }) dependsOn 'build' } @@ -145,3 +141,17 @@ license { task check { dependsOn checkLicenses } + +def setEnvironmentForDockerBuild(environment){ + environment "VERSION", dockerTag + environment "COMMIT_SHA", revision + environment "IMAGE", dockerRepository + + if (project.hasProperty("isHotfix")) { + environment "IS_HOTFIX", isHotfix + println("Setting hotfix to ${isHotfix}") + } else { + environment "IS_HOTFIX", true + println("'isHotfix'-Property not defined. Assuming hotfix release") + } +}