Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bayernId-proxy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OZG-Cloud
app
bayernId-proxy
Commits
f9e6f121
Commit
f9e6f121
authored
6 months ago
by
Zhenzhen Liu
Browse files
Options
Downloads
Patches
Plain Diff
OZG-6923 add commitId to feature branch image tag/helm version
parent
965ec8ca
No related branches found
No related tags found
1 merge request
!3
OZG-6923 add commitId to feature branch image tag/helm version
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Jenkinsfile
+17
-22
17 additions, 22 deletions
Jenkinsfile
with
17 additions
and
22 deletions
Jenkinsfile
+
17
−
22
View file @
f9e6f121
...
...
@@ -107,7 +107,7 @@ pipeline {
steps
{
script
{
FAILED_STAGE
=
env
.
STAGE_NAME
IMAGE_TAG_BAYERN_ID_PROXY
=
generateImageTag
(
'pom.xml'
)
IMAGE_TAG_BAYERN_ID_PROXY
=
buildVersionName
(
'pom.xml'
)
tagAndPushDockerImage
(
'bayernid-proxy'
,
IMAGE_TAG_BAYERN_ID_PROXY
)
...
...
@@ -127,7 +127,7 @@ pipeline {
script
{
FAILED_STAGE
=
env
.
STAGE_NAME
HELM_CHART_VERSION_BAYERN_ID_PROXY
=
generateHelmChart
Version
(
"pom.xml"
)
HELM_CHART_VERSION_BAYERN_ID_PROXY
=
build
Version
Name
(
"pom.xml"
)
sh
"./run_helm_test.sh"
...
...
@@ -178,7 +178,7 @@ pipeline {
stage
(
'Deploy SBOM to DependencyTrack'
)
{
steps
{
script
{
IMAGE_TAG
=
generateImageTag
(
'pom.xml'
)
IMAGE_TAG
=
buildVersionName
(
'pom.xml'
)
configFileProvider
([
configFile
(
fileId:
'maven-settings'
,
variable:
'MAVEN_SETTINGS'
)])
{
withCredentials
([
string
(
credentialsId:
'dependency-track-api-key'
,
variable:
'API_KEY'
)])
{
...
...
@@ -253,17 +253,22 @@ void deployHelmChart(String helmChartName, String helmChartVersion) {
}
}
String
generateHelmChartVersion
(
String
pomFile
)
{
def
chartVersion
=
getPomVersion
(
pomFile
)
if
(
env
.
BRANCH_NAME
==
'main'
)
{
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
(
String
pomFile
)
{
if
(
isReleaseBranch
())
{
return
getPomVersion
(
pomFile
)
}
return
"${getPomVersion(pomFile)}-${validateBranchName(env.BRANCH_NAME)}-${env.GIT_COMMIT.take(7)}"
.
replaceAll
(
"_"
,
"-"
)
}
Void
tagAndPushDockerImage
(
String
imageName
,
String
newTag
){
...
...
@@ -281,16 +286,6 @@ String getPomVersion(String pomFile){
return
pom
.
version
}
String
generateImageTag
(
String
pomFile
)
{
def
imageTag
=
"${env.BRANCH_NAME}-${getPomVersion(pomFile)}"
if
(
env
.
BRANCH_NAME
==
'main'
)
{
imageTag
+=
"-${env.GIT_COMMIT.take(7)}"
}
return
imageTag
}
String
generateBranchPRJarTag
(
String
pomFile
)
{
def
jarTag
=
getPomVersion
(
pomFile
).
replace
(
"SNAPSHOT"
,
"${env.BRANCH_NAME}-SNAPSHOT"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment