Skip to content
Snippets Groups Projects
Commit d29620f9 authored by OZGCloud's avatar OZGCloud
Browse files

Merge pull request 'OZG-6923 add commitId to feature branch image tag/helm...

Merge pull request 'OZG-6923 add commitId to feature branch image tag/helm version' (#5) from OZG-6923 into master

Reviewed-on: https://git.ozg-sh.de/ozgcloud-app/token-checker/pulls/5


Reviewed-by: default avatarOZGCloud <ozgcloud@mgm-tp.com>
parents add7bde1 cb0dc8af
Branches
No related tags found
No related merge requests found
......@@ -100,7 +100,7 @@ pipeline {
steps {
script {
FAILED_STAGE=env.STAGE_NAME
IMAGE_TAG = generateImageTag()
IMAGE_TAG = buildVersionName()
tagAndPushDockerImage(IMAGE_TAG)
......@@ -119,7 +119,7 @@ pipeline {
steps {
script {
FAILED_STAGE=env.STAGE_NAME
HELM_CHART_VERSION = generateHelmChartVersion()
HELM_CHART_VERSION = buildVersionName()
dir('token-checker-server') {
sh "./run_helm_test.sh"
......@@ -232,16 +232,6 @@ String getPomVersion(String pomFile){
return pom.version
}
String generateImageTag() {
def imageTag = "${env.BRANCH_NAME}-${getPomVersion('pom.xml')}"
if (env.BRANCH_NAME == 'master') {
imageTag += "-${env.GIT_COMMIT.take(7)}"
}
return imageTag
}
Void configureGit() {
final email = "jenkins@ozg-sh.de"
final name = "jenkins"
......@@ -297,17 +287,22 @@ Void loginToDockerRepo() {
}
String generateHelmChartVersion() {
def chartVersion = getPomVersion('pom.xml')
if (env.BRANCH_NAME == 'master') {
chartVersion += "-${env.GIT_COMMIT.take(7)}"
String validateBranchName(branchName) {
int maxLength = 30
if (branchName.length() > maxLength) {
String originalBranchName = branchName
branchName = branchName.substring(0, maxLength)
echo "WARNING: Branch name '${originalBranchName}' exceeded ${maxLength} characters. " +
"It has been truncated to '${branchName}' for deployment purposes."
}
else if (env.BRANCH_NAME != 'release') {
chartVersion += "-${env.BRANCH_NAME}"
return branchName
}
return chartVersion.replaceAll("_", "-")
String buildVersionName() {
if (env.BRANCH_NAME == 'release') {
return getPomVersion('pom.xml')
}
return "${getPomVersion('pom.xml')}-${validateBranchName(env.BRANCH_NAME)}-${env.GIT_COMMIT.take(7)}".replaceAll("_", "-")
}
Void tagAndPushDockerImage(String newTag){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment