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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OZG-Cloud
app
administration
Commits
01849e4b
Commit
01849e4b
authored
1 year ago
by
OZGCloud
Browse files
Options
Downloads
Patches
Plain Diff
OZG-4786 OZG-4792 Docker image is pushed
parent
70f75a64
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
-8
16 additions, 8 deletions
Jenkinsfile
with
16 additions
and
8 deletions
Jenkinsfile
+
16
−
8
View file @
01849e4b
...
@@ -11,6 +11,7 @@ pipeline {
...
@@ -11,6 +11,7 @@ pipeline {
SNAPSHOT_REGEX
=
/\d+.\d+.\d+-SNAPSHOT/
SNAPSHOT_REGEX
=
/\d+.\d+.\d+-SNAPSHOT/
FAILED_STAGE
=
""
FAILED_STAGE
=
""
SH_SUCCESS_STATUS_CODE
=
0
SH_SUCCESS_STATUS_CODE
=
0
IMAGE_TAG
=
generateImageTag
()
}
}
options
{
options
{
...
@@ -72,7 +73,6 @@ pipeline {
...
@@ -72,7 +73,6 @@ pipeline {
steps
{
steps
{
script
{
script
{
FAILED_STAGE
=
env
.
STAGE_NAME
FAILED_STAGE
=
env
.
STAGE_NAME
IMAGE_TAG
=
generateImageTag
()
}
}
configFileProvider
([
configFile
(
fileId:
'maven-settings'
,
variable:
'MAVEN_SETTINGS'
)])
{
configFileProvider
([
configFile
(
fileId:
'maven-settings'
,
variable:
'MAVEN_SETTINGS'
)])
{
...
@@ -86,14 +86,14 @@ pipeline {
...
@@ -86,14 +86,14 @@ pipeline {
script
{
script
{
FAILED_STAGE
=
env
.
STAGE_NAME
FAILED_STAGE
=
env
.
STAGE_NAME
tagAndPushDockerImage
(
IMAGE_TAG
)
if
(
env
.
BRANCH_NAME
==
'master'
)
{
if
(
env
.
BRANCH_NAME
==
'master'
)
{
t
agAndPushDockerImage
(
'snapshot-latest'
)
reT
agAndPushDockerImage
(
'snapshot-latest'
)
}
}
else
if
(
env
.
BRANCH_NAME
==
'release'
)
{
else
if
(
env
.
BRANCH_NAME
==
'release'
)
{
tagAndPushDockerImage
(
'latest'
)
reTagAndPushDockerImage
(
'latest'
)
}
else
{
pushDockerImage
()
}
}
}
}
}
}
...
@@ -171,15 +171,23 @@ pipeline {
...
@@ -171,15 +171,23 @@ pipeline {
Void
t
agAndPushDockerImage
(
String
newTag
){
Void
reT
agAndPushDockerImage
(
String
newTag
){
withCredentials
([
usernamePassword
(
credentialsId:
'jenkins-nexus-login'
,
usernameVariable:
'USER'
,
passwordVariable:
'PASSWORD'
)])
{
withCredentials
([
usernamePassword
(
credentialsId:
'jenkins-nexus-login'
,
usernameVariable:
'USER'
,
passwordVariable:
'PASSWORD'
)])
{
sh
"docker login docker.ozg-sh.de -u ${USER} -p ${PASSWORD}"
sh
"docker login docker.ozg-sh.de -u ${USER} -p ${PASSWORD}"
sh
"docker tag docker.ozg-sh.de/administration:
build-latest
docker.ozg-sh.de/administration:${newTag}"
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}"
sh
"docker push docker.ozg-sh.de/administration:${newTag}"
}
}
}
}
Void
pushDockerImage
(){
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}"
}
}
String
generateImageTag
()
{
String
generateImageTag
()
{
def
imageTag
=
"${env.BRANCH_NAME}-${getPomVersion('pom.xml')}"
def
imageTag
=
"${env.BRANCH_NAME}-${getPomVersion('pom.xml')}"
...
...
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