Gitlab.com Package Repository on Group level

We are trying to publish packages to out gitlab subgroup on gitlab.com using maven.
We receive error 415 Media Type not supported → same setup works for project level deployment.

settings.xml

<settings>
    <servers>
        <server>
            <id>gitlab-maven</id>
            <configuration>
                <httpHeaders>
                    <property>
                        <name>Private-Token</name>
                        <value>TOKEN VALUE</value>
                    </property>
                </httpHeaders>
            </configuration>
        </server>
    </servers>
</settings>

pom.xml

<repositories>
    <repository>
      <id>gitlab-maven</id>
      <url>https://gitlab.com/api/v4/groups/${gitlab.group.id}/-/packages/maven</url>
    </repository>
  </repositories>
  <distributionManagement>
    <repository>
      <id>gitlab-maven</id>
      <url>https://gitlab.com/api/v4/groups/${gitlab.group.id}/-/packages/maven</url>
    </repository>
    <snapshotRepository>
      <id>gitlab-maven</id>
      <url>https://gitlab.com/api/v4/groups/${gitlab.group.id}/-/packages/maven</url>
    </snapshotRepository>
  </distributionManagement>

Error:

Failed to deploy artifacts: Could not transfer artifact groupid:artifactid:pom:0.0.1-20240117.161354-3 from/to gitlab-maven (https://gitlab.com/api/v4/groups/XXXX/-/packages/maven): status code: 415, reason phrase: Unsupported Media Type (415)

Maybe related to GitLab CE Group Maven Package Registry - #4 by xenomachina

It mentions the /-/ in the URL that needs to be removed. The endpoint URLs in Maven packages in the package registry | GitLab also do not have them.

-      <url>https://gitlab.com/api/v4/groups/${gitlab.group.id}/-/packages/maven</url>
+      <url>https://gitlab.com/api/v4/groups/${gitlab.group.id}/packages/maven</url>

I have not used the Maven package registry yet, but could be worth a try.

@dnsmichi thanks for your input - I also tried without “/-/” which unfortunately results in the same error.

I see that the pom.xml uses a variable gitlab.group.id – maybe replace and hardcode it to the real group ID for testing. If that is a blind spot, I’d suggest opening an issue and discuss with our engineering teams. Maybe we are hitting a bug with the package registry on the group level.

even with the group id hardcoded the error persists.

I tested publishing on project level → this worked, the problem is only present on group level