From ae0196d44730fae8944be256c239c00a438e3c97 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Thu, 25 Jan 2024 15:09:32 +0100 Subject: [PATCH] OZG-4792 Double tag on master and release, and this brnach for testing --- Jenkinsfile | 23 ++++++++++++++++------- pom.xml | 3 ++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5a866ccc..ea618206 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -73,11 +73,12 @@ pipeline { steps { script { FAILED_STAGE=env.STAGE_NAME + env.BUILD_TAG = generateBuildTag() } configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) { withCredentials([usernamePassword(credentialsId: 'jenkins-nexus-login', usernameVariable: 'USER', passwordVariable: 'PASSWORD')]) { - sh 'mvn -s $MAVEN_SETTINGS spring-boot:build-image -DskipTests -Dmaven.wagon.http.retryHandler.count=3 -Dbuildtag=$IMAGE_TAG -Dspring-boot.build-image.publish=true -Duser=${USER} -Dpassword=${PASSWORD}' + sh 'mvn -s $MAVEN_SETTINGS spring-boot:build-image -DskipTests -Dmaven.wagon.http.retryHandler.count=3 -Dimagetag=$IMAGE_TAG -Dbuildtag=${env.BUILD_TAG} -Dspring-boot.build-image.publish=true -Duser=${USER} -Dpassword=${PASSWORD}' } } } @@ -154,14 +155,22 @@ pipeline { } String generateImageTag() { + return "${env.BRANCH_NAME}-${getPomVersion()}" +} - if (isMasterBranch()) { - return "snapshot-latest" - } - else if (isReleaseBranch()) { - return "latest" +String generateBuildTag() { + + def buildName = "docker.ozg-sh.de/administration" + def buildTag = buildName+":"+IMAGE_TAG + + if (isMasterBranch()) { + buildTag += ","+buildName+":snapshot-latest" + } else if (isReleaseBranch()) { + buildTag += ","+buildName+":latest" + } else if (env.BRANCH_NAME == 'OZG-4792-FixMasterBranchTagging') { + buildTag += ","+buildName+":doubleTagTest" } - return "${env.BRANCH_NAME}-${getPomVersion()}" + return buildTag } String getPomVersion() { diff --git a/pom.xml b/pom.xml index 2b0b19fe..a0ba0f09 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,8 @@ <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <image> - <name>docker.ozg-sh.de/administration:${buildtag}</name> + <name>docker.ozg-sh.de/administration:${imagetag}</name> + <tags>${buildtag}</tags> <publish>true</publish> </image> <docker> -- GitLab