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

View File

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

View File

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