Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
token-checker
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
token-checker
Commits
cb0dc8af
Commit
cb0dc8af
authored
6 months ago
by
OZGCloud
Browse files
Options
Downloads
Patches
Plain Diff
OZG-6923 add commitId to feature branch image tag/helm version
parent
add7bde1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Jenkinsfile
+16
-21
16 additions, 21 deletions
Jenkinsfile
with
16 additions
and
21 deletions
Jenkinsfile
+
16
−
21
View file @
cb0dc8af
...
@@ -100,7 +100,7 @@ pipeline {
...
@@ -100,7 +100,7 @@ pipeline {
steps
{
steps
{
script
{
script
{
FAILED_STAGE
=
env
.
STAGE_NAME
FAILED_STAGE
=
env
.
STAGE_NAME
IMAGE_TAG
=
generateImageTag
()
IMAGE_TAG
=
buildVersionName
()
tagAndPushDockerImage
(
IMAGE_TAG
)
tagAndPushDockerImage
(
IMAGE_TAG
)
...
@@ -119,7 +119,7 @@ pipeline {
...
@@ -119,7 +119,7 @@ pipeline {
steps
{
steps
{
script
{
script
{
FAILED_STAGE
=
env
.
STAGE_NAME
FAILED_STAGE
=
env
.
STAGE_NAME
HELM_CHART_VERSION
=
generateHelmChart
Version
()
HELM_CHART_VERSION
=
build
Version
Name
()
dir
(
'token-checker-server'
)
{
dir
(
'token-checker-server'
)
{
sh
"./run_helm_test.sh"
sh
"./run_helm_test.sh"
...
@@ -232,16 +232,6 @@ String getPomVersion(String pomFile){
...
@@ -232,16 +232,6 @@ String getPomVersion(String pomFile){
return
pom
.
version
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
()
{
Void
configureGit
()
{
final
email
=
"jenkins@ozg-sh.de"
final
email
=
"jenkins@ozg-sh.de"
final
name
=
"jenkins"
final
name
=
"jenkins"
...
@@ -297,17 +287,22 @@ Void loginToDockerRepo() {
...
@@ -297,17 +287,22 @@ Void loginToDockerRepo() {
}
}
String
generateHelmChartVersion
()
{
String
validateBranchName
(
branchName
)
{
def
chartVersion
=
getPomVersion
(
'pom.xml'
)
int
maxLength
=
30
if
(
branchName
.
length
()
>
maxLength
)
{
if
(
env
.
BRANCH_NAME
==
'master'
)
{
String
originalBranchName
=
branchName
chartVersion
+=
"-${env.GIT_COMMIT.take(7)}"
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'
)
{
return
branchName
chartVersion
+=
"-${env.BRANCH_NAME}"
}
}
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
){
Void
tagAndPushDockerImage
(
String
newTag
){
...
...
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