Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xta-test-server
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
lib
xta-test-server
Commits
5d5d2638
Commit
5d5d2638
authored
6 months ago
by
Martin
Browse files
Options
Downloads
Patches
Plain Diff
OZG-7121 extract docker image push into bash script
parent
20bd227d
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!3
Resolve "xta-test-server helm-chart mit Deployment und Keystore-Secrets/Certificate-Resources"
Pipeline
#1145
failed
6 months ago
Stage: build
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Jenkinsfile
+6
-4
6 additions, 4 deletions
Jenkinsfile
script/push-docker-image.sh
+33
-0
33 additions, 0 deletions
script/push-docker-image.sh
with
39 additions
and
4 deletions
Jenkinsfile
+
6
−
4
View file @
5d5d2638
...
...
@@ -286,10 +286,12 @@ String buildVersionName() {
Void
tagAndPushDockerImage
(
String
newTag
){
withCredentials
([
usernamePassword
(
credentialsId:
'jenkins-nexus-login'
,
usernameVariable:
'USER'
,
passwordVariable:
'PASSWORD'
)])
{
sh
'docker login docker.ozg-sh.de -u ${USER} -p ${PASSWORD}'
sh
"docker tag docker.ozg-sh.de/xta-test-server:${getPomVersion()} docker.ozg-sh.de/xta-test-server:${newTag}"
sh
"docker push docker.ozg-sh.de/xta-test-server:${newTag}"
sh
"""
export DOCKER_USER=${USER}
export DOCKER_PASSWORD=${PASSWORD}
export BRANCH_NAME=${env.BRANCH_NAME}
./tag_and_push_docker_image.sh ${newTag} ${getPomVersion()}
"""
}
}
...
...
This diff is collapsed.
Click to expand it.
script/push-docker-image.sh
0 → 100644
+
33
−
0
View file @
5d5d2638
#!/bin/bash
set
-e
NEW_TAG
=
"
$1
"
POM_VERSION
=
"
$2
"
DOCKER_REGISTRY
=
"docker.ozg-sh.de"
IMAGE_NAME
=
"xta-test-server"
if
[
-z
"
$DOCKER_USER
"
]
;
then
echo
"Error: USER environment variable must be set"
exit
1
fi
if
[
-z
"
$DOCKER_PASSWORD
"
]
;
then
echo
"Error: PASSWORD environment variable must be set"
exit
1
fi
if
[
-z
"
$BRANCH_NAME
"
]
;
then
echo
"Error: BRANCH_NAME environment variable must be set"
exit
1
fi
echo
"BRANCH_NAME:
${
BRANCH_NAME
}
"
echo
"Log into Docker..."
echo
"
$DOCKER_PASSWORD
"
| docker login
"
$DOCKER_REGISTRY
"
-u
"
$DOCKER_USER
"
--password-stdin
echo
"Tag Docker image..."
docker tag
"
${
DOCKER_REGISTRY
}
/
${
IMAGE_NAME
}
:
${
POM_VERSION
}
"
"
${
DOCKER_REGISTRY
}
/
${
IMAGE_NAME
}
:
${
NEW_TAG
}
"
echo
"Push Docker image..."
docker push
"
${
DOCKER_REGISTRY
}
/
${
IMAGE_NAME
}
:
${
NEW_TAG
}
"
echo
"Docker image pushed successfully:
${
DOCKER_REGISTRY
}
/
${
IMAGE_NAME
}
:
${
NEW_TAG
}
"
\ No newline at end of file
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