Prevent latest docker tag for hotfix releases

Pushed-by: Florian Scholdei<florian.scholdei@cloudogu.com>
Co-authored-by: Florian Scholdei<florian.scholdei@cloudogu.com>
Committed-by: Florian Scholdei<florian.scholdei@cloudogu.com>
This commit is contained in:
Florian Scholdei
2024-03-20 10:59:28 +01:00
parent 708d743b2c
commit 8e44bd1c08
3 changed files with 12 additions and 2 deletions

6
Jenkinsfile vendored
View File

@@ -120,7 +120,7 @@ pipeline {
} }
steps { steps {
withPublishEnvironment { withPublishEnvironment {
gradle "-PenablePackaging publish" gradle "-PenablePackaging publish -PisHotfix=${isHotfixBuild()}"
} }
} }
} }
@@ -266,6 +266,10 @@ boolean isReleaseBuild() {
return env.BRANCH_NAME.startsWith('release/') return env.BRANCH_NAME.startsWith('release/')
} }
boolean isHotfixBuild() {
return env.BRANCH_NAME.startsWith('hotfix/')
}
String getReleaseVersion() { String getReleaseVersion() {
if (isReleaseBuild()) { if (isReleaseBuild()) {
return env.BRANCH_NAME.substring("release/".length()); return env.BRANCH_NAME.substring("release/".length());

View File

@@ -94,6 +94,7 @@ task build(type: Exec) {
environment "VERSION", dockerTag environment "VERSION", dockerTag
environment "COMMIT_SHA", revision environment "COMMIT_SHA", revision
environment "IMAGE", dockerRepository environment "IMAGE", dockerRepository
environment "IS_HOTFIX", isHotfix
doLast { doLast {
File file = new File(project.buildDir, 'docker.tag') File file = new File(project.buildDir, 'docker.tag')
@@ -107,6 +108,7 @@ task pushImages(type: Exec) {
environment "VERSION", dockerTag environment "VERSION", dockerTag
environment "COMMIT_SHA", revision environment "COMMIT_SHA", revision
environment "IMAGE", dockerRepository environment "IMAGE", dockerRepository
environment "IS_HOTFIX", isHotfix
dependsOn 'build' dependsOn 'build'
} }

View File

@@ -41,6 +41,10 @@ variable "IMAGE" {
default = "docker.io/cloudogu/scm-manager" default = "docker.io/cloudogu/scm-manager"
} }
variable "IS_HOTFIX" {
default = false
}
target "base" { target "base" {
context = "." context = "."
args = { args = {
@@ -69,7 +73,7 @@ target "alpine" {
inherits = ["base"] inherits = ["base"]
dockerfile = "Dockerfile.alpine" dockerfile = "Dockerfile.alpine"
tags = [ tags = [
"${IMAGE}:latest", IS_HOTFIX ? "" : "${IMAGE}:latest",
"${IMAGE}:${VERSION}", "${IMAGE}:${VERSION}",
"${IMAGE}:${VERSION}-alpine" "${IMAGE}:${VERSION}-alpine"
] ]