Commit 464d5f56 authored by Benavides Ontiveros's avatar Benavides Ontiveros
Browse files

verify docker push and login

parent f1a99067
Pipeline #12174 failed
...@@ -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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment