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
26c001e2
Commit
26c001e2
authored
Nov 28, 2025
by
Benavides Ontiveros
Browse files
verify docker push and login
parent
464d5f56
Pipeline
#12175
passed with stages
in 20 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
26c001e2
...
...
@@ -93,7 +93,6 @@ build:
--build-arg REDDIT_CLIENT_ID="$REDDIT_CLIENT_ID" \
--build-arg REDDIT_CLIENT_SECRET="$REDDIT_CLIENT_SECRET" \
-t $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA .
after_script
:
-
echo "Docker image built successfully!"
rules
:
...
...
@@ -109,34 +108,27 @@ build:
deploy
:
stage
:
deploy
extends
:
.build_template
script
:
-
echo "Logging in to Docker registry..."
-
echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin
script
:
|
echo "Logging in to Docker registry..."
echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin
# 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
docker info | grep Username || (echo "Docker login failed!" && exit 1)
# Push the commit-specific tag
-
echo "Pushing Docker image
:
$DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA"
-
docker push $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA
echo "Listing local Docker images before push..."
docker images
# If default branch, also tag as latest and push
-
|
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 "Pushing Docker image: $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA"
docker push $DOCKERHUB_REPO:$CI_COMMIT_SHORT_SHA
# List images after push
-
echo "Final list of local Docker images:"
-
docker images
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
rules
:
-
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