Hello everyone!
Not sure if anybody already experienced this and has a solution other than "Change your workspace name to lowercase to get it working" (which sadly is not a solution as I can't do that because it's a company wide workspace across multiple departments and would cause huge trouble).
Problem:
- The Workspace name is mixed case like MyCompany_CORP.
- When building a docker image, docker requests the repository name to be all lowercase and errors out if it is not.
- If I change everything to lowercase, the BitBucket registry will throw an error and tell me that the name does not exist or I may not have access.
- I can't create a Container Package with lowercase name as the workspace is prefilled and I can only add the repository name (last part).
- As a result, I'm unable to push any docker images to the BitBucket Container Packages.
Steps to reproduce:
- Create a mixed case workspace.
- Create a repository in that workspace.
- Create a bare bones bitbucket-pipelines.yml file inside like the one attached at the end of this post.
- Save this inside the newly created repository.
- Pipeline will be started.
- Pipeline will Fail with the error: Bad Request ("invalid reference format: repository name (MyCompany_CORP/testrepo) must be lowercase")
- Update the bitbucket-pipelines.yml file with the contents of the second file attached at the end and save it in the repository.
- Pipeline will fail with the error: name unknown: You may not have access to this image or it does not exist in this workspace.
Thank you very much for your help and have a lovely day!
All the best.
Tom
First bitbucket-pipelines.yml file:
pipelines:
default:
- step:
name: docker-build
services:
- docker
caches:
- docker
script:
- docker build -t testrepo:latest .
- pipe: atlassian/bbc-packages-push-container-image:1.0.7
variables:
IMAGE_NAME: "testrepo"
Second bucket-pipelines.yml file:
pipelines:
default:
- step:
name: docker-build
services:
- docker
caches:
- docker
script:
- export REPO_SLUG_LOWER=$(echo "$BITBUCKET_REPO_SLUG" | tr '[:upper:]' '[:lower:]')
- export WORKSPACE_LOWER=$(echo "$BITBUCKET_WORKSPACE" | tr '[:upper:]' '[:lower:]')
- docker login crg.apkg.io -u "$BITBUCKET_PACKAGES_USERNAME" -p "$BITBUCKET_PACKAGES_TOKEN"
- docker build -t "crg.apkg.io/$WORKSPACE_LOWER/$REPO_SLUG_LOWER:latest" .
- docker push "crg.apkg.io/$WORKSPACE_LOWER/$REPO_SLUG_LOWER:latest"