kaibloecker / semantic-release-docker-gitlab-ci

semantic-release plugin to publish to GitLab Container Registry
MIT License
2 stars 2 forks source link

Error: undefined TypeError: Cannot read properties of undefined (reading 'split') #33

Open Dextererials opened 1 year ago

Dextererials commented 1 year ago

I am getting an error message undefined TypeError: Cannot read properties of undefined (reading 'split') when I try to add the plugin semantic-release-docker-gitlab-ci. The error is getting thrown from semantic-release-docker-gitlab-ci/src/verify.js:35:1 Not sure what I am doing wrong. Here is my config files:

stages:
  - build
  - release

# Build docker image
build:
  image: docker:20.10
  stage: build
  dependencies:
    - setup-netrc
  services:
    - docker:23-dind
  before_script:
    - echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
  script:
    - docker build --secret id=netrc,src=netrc/.netrc --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
    - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA

# Run Release
semantic-release:
  image: node:lts
  stage: release
  variables:
    GITLAB_TOKEN: ${GITLAB_ACCESS_TOKEN}
  before_script:
    - apt-get update
    - npm install semantic-release @semantic-release/gitlab @semantic-release/release-notes-generator @semantic-release/commit-analyzer semantic-release-docker-gitlab-ci
  script:
    - npx semantic-release
casparbauer commented 2 months ago

I have just been able to reproduce this. It relates to the project name (or groups) including uppercase letters. While the gitlab repository path can contain uppercase letters (eg. git@gitlab.com/group/Foo-Service), the gitlab registry can not (the equivalent created by gitlab will be registry.gitlab.com/group/foo-service). https://github.com/kaibloecker/semantic-release-docker-gitlab-ci/blob/main/src/auth.js#L34 does not take this into account (PROJECT_PATH needs to be .toLowerCase()'ed).

@Dextererials as a manual workaround: You have to ensure that the repository path is lower case. You sadly can not just change the path, since gitlab considers the underlying registry path as already taken. Therefore you have the change the repository path twice: Eg. first to gitlab.com/group/foo-service-2 and then to gitlab.com/group/foo-service

@kaibloecker would you accept a patch that lower cases PROJECT_PATH?