I am trying to publish some jar artefacts on gitlab package registry but I get this error from the server :
Received status code 415 from server: Unsupported Media Type
Here is the publishing section of my build.gradle.kts :
publishing {
publications {
create<MavenPublication>("maven"){
artifact(tasks["bootJar"])
}
}
repositories {
maven {
url = uri("https://gitlab.com/api/v4/groups/my-group/-/packages/maven")
name = "Gitlab"
credentials(HttpHeaderCredentials::class) {
name = "Token"
value = System.getenv("CI_JOB_TOKEN")
}
authentication {
create<HttpHeaderAuthentication>("header")
}
}
}
}
In my gitlab-ci, I added a task for publish the artefacts :
deploy:
stage: deploy
script: gradle publish
only:
- master
Any help would be appreciated
Quick answer
Replace your publishing url pointing to the group-scope with the one pointing to the specific-package-repository, e.g. on
gitlab.com
:https://gitlab.com/api/v4/projects/<your-project-id>/packages/maven
You need to replace
<your-project-id>
with your specific project-id of course.Related to this a quote from docs.gitlab:
Or in other words: Only the general repositories section can use your groups-url for searching other already published artifacts! (I also had to understand that). So:
Example gradle config (kotlin-dsl)
More Info
There are multiple scenarios on how you may interact with the maven-repository-space on GitLab. The three switches are:
https://.../api/v4/projects/<project-id>/packages/maven
)https://.../api/v4/groups/<group-id>/-/packages/maven
)https://.../api/v4/packages/maven
)https://.../api/v4/projects/<project-id>/packages/maven
)