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

OZG-6923 add commitId to feature branch image tag/helm version

parent 4d0f6f89
No related branches found
No related tags found
No related merge requests found
......@@ -117,7 +117,7 @@ pipeline {
steps {
script {
FAILED_STAGE=env.STAGE_NAME
IMAGE_TAG = generateImageTag()
IMAGE_TAG = buildVersionName()
tagAndPushDockerImage('intelliform-adapter', IMAGE_TAG)
tagAndPushDockerImage('formsolutions-adapter', IMAGE_TAG)
......@@ -147,7 +147,7 @@ pipeline {
steps {
script {
FAILED_STAGE=env.STAGE_NAME
HELM_CHART_VERSION = generateHelmChartVersion()
HELM_CHART_VERSION = buildVersionName()
sh "./run_helm_test.sh"
......@@ -164,7 +164,7 @@ pipeline {
steps {
script {
FAILED_STAGE=env.STAGE_NAME
HELM_CHART_VERSION = generateHelmChartVersion()
HELM_CHART_VERSION = buildVersionName()
dir('xta-adapter') {
sh "./run_helm_test.sh"
......@@ -216,7 +216,7 @@ pipeline {
stage ('Deploy SBOM to DependencyTrack') {
steps {
script {
IMAGE_TAG = generateImageTag()
IMAGE_TAG = buildVersionName()
configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) {
withCredentials([string(credentialsId: 'dependency-track-api-key', variable: 'API_KEY')]) {
......@@ -257,17 +257,22 @@ Void deployHelmChart(String helmChartName, String helmChartVersion) {
}
}
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 sendFailureMessage() {
......@@ -428,16 +433,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
}
String getParentPomVersion(String filePath) {
def pom = readMavenPom file: filePath
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