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
464d5f56
Commit
464d5f56
authored
Nov 28, 2025
by
Benavides Ontiveros
Browse files
verify docker push and login
parent
f1a99067
Pipeline
#12174
failed
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
464d5f56
...
@@ -112,13 +112,31 @@ deploy:
...
@@ -112,13 +112,31 @@ deploy:
script
:
script
:
-
echo "Logging in to Docker registry..."
-
echo "Logging in to Docker registry..."
-
echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin
-
echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin
-
echo "Pushing Docker image..."
# Verify login
-
echo "Verifying Docker login..."
-
docker info | grep Username || (echo "Docker login failed!" && exit 1)
# List images before push
-
echo "Listing local Docker images..."
-
docker images
# Push the commit-specific tag
-
echo "Pushing Docker image
:
$DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA"
-
docker push $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA
-
docker push $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA
# If default branch, also tag as latest and push
-
|
-
|
if [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then
if [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then
echo "Tagging image as latest..."
echo "Tagging image as latest..."
docker tag $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA $DOCKERHUB_REPO:latest
docker tag $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA $DOCKERHUB_REPO:latest
echo "Pushing latest tag..."
docker push $DOCKERHUB_REPO:latest
docker push $DOCKERHUB_REPO:latest
fi
fi
# List images after push
-
echo "Final list of local Docker images:"
-
docker images
rules
:
rules
:
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH'
-
if
:
'
$CI_COMMIT_BRANCH
==
$CI_DEFAULT_BRANCH'
\ 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