I want to push my built images to docker hub with the same tags like the commit tag but get this error message:
Error parsing reference: "bruyland/nest-appinfo-test:" is not a valid repository/tag: invalid reference format
It's obvious that the `$BITBUCKET_TAG` variable is empty, but I dpon't understand why.
Here's the pipeline, I've been following this recipe: https://think-engineer.com/blog/devops/bitbucket-pipelines-building-publishing-and-re-tagging-docker-images-in-a-ci-cd-workflow
options:
docker: true
steps:
- step: &build-and-push
size: 2x
name: build and push docker image
script:
# build the Docker image
# origional IMAGE_NAME export IMAGE_NAME=myorg/myapp:$BITBUCKET_BRANCH-$BITBUCKET_COMMIT
- export IMAGE_NAME=bruyland/$BITBUCKET_REPO_SLUG
- echo '"$IMAGE_NAME"'
- docker build --build-arg COMMIT=$BITBUCKET_COMMIT --build-arg TAG=$BITBUCKET_TAG -t $IMAGE_NAME .
# authenticate with the Docker Hub registry
- docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD
# push the new Docker image to the Docker registry
- docker push $IMAGE_NAME
pipelines:
branches:
develop:
- step: *build-and-push
master:
- step: *build-and-push
tags:
'*':
# - step: *build-and-push
- step:
name: retag and repush image
script:
# get the image that was built in the master branch
- export IMAGE_NAME=bruyland/$BITBUCKET_REPO_SLUG
- echo '"$BITBUCKET_TAG"'
- export NEW_IMAGE_NAME=$IMAGE_NAME:$BITBUCKET_TAG
# authenticate with the Docker Hub registry
- docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD
# pull the image down
- docker pull $IMAGE_NAME
# retag the image using the git tag
- docker tag $IMAGE_NAME $NEW_IMAGE_NAME
# push the image back
- docker push $NEW_IMAGE_NAME
Found the problem, forgot to add `--tags` to the git push command.
Sorry for asking such a stupid question
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.