Skip to content
Snippets Groups Projects
Commit 9b24c50f authored by Martin's avatar Martin
Browse files

adjust JenkinsFile#buildImageTag

parent 28840c84
No related branches found
No related tags found
No related merge requests found
...@@ -373,15 +373,29 @@ String getPomVersion(String pomFile){ ...@@ -373,15 +373,29 @@ String getPomVersion(String pomFile){
} }
String generateImageTag() { String generateImageTag() {
def imageTag = "${env.BRANCH_NAME}-${getPomVersion('pom.xml')}" if (isReleaseBranch()) {
return getPomVersion()
}
if (env.BRANCH_NAME == 'main') { return "${getPomVersion()}-${validateBranchName(env.BRANCH_NAME)}${getCommitHash()}".replaceAll("_", "-")
imageTag += "-${env.GIT_COMMIT.take(7)}"
} }
return imageTag String validateBranchName(branchName) {
int maxLength = 20
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."
}
return branchName
} }
String getCommitHash() {
return "-${env.GIT_COMMIT.take(7)}";
}
String getParentPomVersion(String filePath) { String getParentPomVersion(String filePath) {
def pom = readMavenPom file: filePath def pom = readMavenPom file: filePath
return pom.parent.version return pom.parent.version
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment