Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fachstellen-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
fachstellen-proxy
Commits
766b1383
Commit
766b1383
authored
5 months ago
by
OZGCloud
Browse files
Options
Downloads
Patches
Plain Diff
OZG-6923 add commitId to feature branch image tag/helm version
parent
8c544b7b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Jenkinsfile
+16
-17
16 additions, 17 deletions
Jenkinsfile
with
16 additions
and
17 deletions
Jenkinsfile
+
16
−
17
View file @
766b1383
...
...
@@ -106,7 +106,7 @@ tools { go 'go-1.22.0' }
sh
"docker build -t docker.ozg-sh.de/fachstellen-proxy:${env.APP_VERSION} ."
IMAGE_TAG
=
generateImageTag
()
IMAGE_TAG
=
buildVersionName
()
tagAndPushDockerImage
(
'fachstellen-proxy'
,
IMAGE_TAG
)
...
...
@@ -124,7 +124,7 @@ tools { go 'go-1.22.0' }
steps
{
script
{
FAILED_STAGE
=
env
.
STAGE_NAME
HELM_CHART_VERSION
=
generateHelmChart
Version
()
HELM_CHART_VERSION
=
build
Version
Name
()
dir
(
'src/main/helm'
)
{
sh
"helm lint -f ../../test/helm-linter-values.yaml"
...
...
@@ -195,12 +195,6 @@ String getHelmRepository(){
return
'ozg-base-apps-snapshot'
;
}
String
generateImageTag
()
{
return
"${env.APP_VERSION}-${env.BRANCH_NAME}"
}
String
getBuildProfile
()
{
if
(
isMasterBranch
())
{
return
"-P master"
...
...
@@ -315,17 +309,22 @@ Boolean isReleaseBranch() {
return
env
.
BRANCH_NAME
==
'release'
}
String
generateHelmChartVersion
()
{
def
chartVersion
=
"${env.APP_VERSION}"
if
(
isMasterBranch
())
{
chartVersion
+=
"-${env.GIT_COMMIT.take(7)}"
}
else
if
(!
isReleaseBranch
())
{
chartVersion
+=
"-${env.BRANCH_NAME}"
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."
}
return
branchName
}
return
chartVersion
.
replaceAll
(
"_"
,
"-"
)
String
buildVersionName
()
{
if
(
isReleaseBranch
())
{
return
env
.
APP_VERSION
}
return
"${env.APP_VERSION}-${validateBranchName(env.BRANCH_NAME)}-${env.GIT_COMMIT.take(7)}"
.
replaceAll
(
"_"
,
"-"
)
}
Void
tagAndPushDockerImage
(
String
imageName
,
String
newTag
){
withCredentials
([
usernamePassword
(
credentialsId:
'jenkins-nexus-login'
,
usernameVariable:
'USER'
,
passwordVariable:
'PASSWORD'
)])
{
...
...
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