Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
administration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
administration
Commits
683b527b
Commit
683b527b
authored
1 year ago
by
OZGCloud
Browse files
Options
Downloads
Patches
Plain Diff
OZG-4786 OZG-4792 Different kind of docker image tags for master and release branch
parent
9d62a6aa
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
+12
-42
12 additions, 42 deletions
Jenkinsfile
with
12 additions
and
42 deletions
Jenkinsfile
+
12
−
42
View file @
683b527b
...
@@ -84,28 +84,7 @@ pipeline {
...
@@ -84,28 +84,7 @@ pipeline {
}
}
}
}
// stage('Tag and Push Docker image') {
// steps {
// script {
// FAILED_STAGE=env.STAGE_NAME
// if (env.BRANCH_NAME == 'master') {
// reTagAndPushDockerImage('snapshot-latest')
// }
// else if (env.BRANCH_NAME == 'release') {
// reTagAndPushDockerImage('latest')
// }
// else {
// pushDockerImage()
// }
// }
// }
// }
stage
(
'Sonar Checks'
)
{
stage
(
'Sonar Checks'
)
{
// when {
// branch 'master'
// }
steps
{
steps
{
script
{
script
{
FAILED_STAGE
=
env
.
STAGE_NAME
FAILED_STAGE
=
env
.
STAGE_NAME
...
@@ -172,31 +151,22 @@ pipeline {
...
@@ -172,31 +151,22 @@ pipeline {
}
}
}
}
String
generateImageTag
()
{
def
imageTag
=
""
Void
reTagAndPushDockerImage
(
String
newTag
){
if
(
env
.
BRANCH_NAME
==
'master'
)
{
withCredentials
([
usernamePassword
(
credentialsId:
'jenkins-nexus-login'
,
usernameVariable:
'USER'
,
passwordVariable:
'PASSWORD'
)])
{
imageTag
+=
"snapshot-latest"
sh
"docker login docker.ozg-sh.de -u ${USER} -p ${PASSWORD}"
sh
"docker tag docker.ozg-sh.de/administration:${IMAGE_TAG} docker.ozg-sh.de/administration:${newTag}"
sh
"docker push docker.ozg-sh.de/administration:${newTag}"
}
}
}
else
if
(
env
.
BRANCH_NAME
==
'release'
)
{
Void
pushDockerImage
(){
imageTag
+=
"latest"
withCredentials
([
usernamePassword
(
credentialsId:
'jenkins-nexus-login'
,
usernameVariable:
'USER'
,
passwordVariable:
'PASSWORD'
)])
{
sh
"docker login docker.ozg-sh.de -u ${USER} -p ${PASSWORD}"
sh
"docker push docker.ozg-sh.de/administration:${IMAGE_TAG}"
}
}
else
{
imageTag
+=
"${env.BRANCH_NAME}-${getPomVersion('pom.xml')}"
}
}
String
generateImageTag
()
{
// if (env.BRANCH_NAME == 'master') {
def
imageTag
=
"${env.BRANCH_NAME}-${getPomVersion('pom.xml')}"
// imageTag += "-${env.GIT_COMMIT.take(7)}"
// }
if
(
env
.
BRANCH_NAME
==
'master'
)
{
imageTag
+=
"-${env.GIT_COMMIT.take(7)}"
}
return
imageTag
return
imageTag
}
}
...
...
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