Maven groups repo/package repo not working

I have a group with 2 maven projects. One is a parent of the other.

After maven deploy of the parent, I see the corresponding snapshot artifact under {my group} → Packages & Repositories → Package Registry. When I click on it, it shows the URL with which I should be able to access the package. Something like:

https://gitlab.com/api/v4/projects/{project-id}/packages/maven

When I curl it passing a valid PRIVATE-TOKEN header, I get:

{“error”:“package_id is invalid”}

If I curl https://gitlab.com/api/v4/projects/{project-id}, I get a valid response.

Similarly when I curl https://gitlab.com/api/v4/groups/{my-group-id}/-/packages/maven, I get {“error”:“404 Not Found”}, whereas curling https://gitlab.com/api/v4/groups/{my-group-id}, gets the me the group information.

To verify that you have the right URL with curl, you’ll need to add a $GROUP/$ARTIFACT/maven-metadata.xml suffix on to those URLs:

curl -H "Private-Token: $PAT" \
  https://gitlab.com/api/v4/projects/$PROJECT_ID/packages/maven/$GROUP/$ARTIFACT/maven-metadata.xml

curl -H "Private-Token: $PAT" \
  https://gitlab.com/api/v4/groups/$GROUP_ID/-/packages/maven/$GROUP/$ARTIFACT/maven-metadata.xml

where:

  • $PAT is a private access token
  • $PROJECT_ID is the numeric GitLab project ID
  • $GROUP_ID is the numeric GitLab group ID
  • $GROUP is the maven group name in slash form (eg: “com/example”, not “com.example”)
  • $ARTIFACT is the maven artifact name

Either of these should give you XML with all of the published versions of the artifact in question.