Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
software-project-WS25
Reddit Team
Commits
acd183ea
Commit
acd183ea
authored
Nov 28, 2025
by
Benavides Ontiveros
Browse files
test docker deploy
parent
b5cc4879
Pipeline
#12180
passed with stages
in 21 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
acd183ea
...
...
@@ -107,28 +107,22 @@ build:
# =====================================================================
deploy
:
stage
:
deploy
extends
:
.build_template
script
:
|
echo "Logging in to Docker registry..."
echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin
# Verify login
docker info | grep Username || (echo "Docker login failed!" && exit 1)
echo "Listing local Docker images before push..."
docker images
echo "Pushing Docker image: $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA"
docker push $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA
if [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then
echo "Tagging image as latest..."
docker tag $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA $DOCKERHUB_REPO:latest
echo "Pushing latest tag..."
docker push $DOCKERHUB_REPO:latest
fi
echo "Listing local Docker images after push..."
docker images
image
:
docker:24.0.9
tags
:
[
"
ubuntu"
,
"
vm"
]
script
:
-
echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin
-
echo "Logged into dockerhub succesfully!!"
-
docker push $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA
-
echo "Pushed the docker image to dockerhub succesfully!"
-
if [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then
docker tag $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA $DOCKERHUB_REPO:latest;
docker push $DOCKERHUB_REPO:latest;
fi
rules
:
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH'
\ No newline at end of file
# Deploy only on default branch (e.g., main) pipelines; never on MRs or tags
-
if
:
'
$CI_PIPELINE_SOURCE
==
"merge_request_event"'
when
:
never
-
if
:
'
$CI_COMMIT_TAG'
when
:
never
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH'
-
when
:
never
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment