401 Unauthorized error when uploading maven package to project registry

Hi all,

I work with a self-managed GitLab (Community Edition, v13.8.8) instance at the University of Bergen.

  • Our main project uses maven and it builds the package properly, but when I try to upload it to the project package registry I always get this error:

Caused by: org.eclipse.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact no.nels:nels.core:jar:1.0 from/to uib-gitlab-maven (https://git.app.uib.no/api/v4/projects/1719/packages/maven): authentication failed for https://git.app.uib.no/api/v4/projects/1719/packages/maven/no/nels/nels.core/1.0/nels.core-1.0.jar, status: 401 Unauthorized

  • I’ve tried different approaches: (deploy tokens, project access tokens…)) but I’m always shown an
    unauthorised response when trying to publish any artifact, even when I’m the owner of the project.
    I have the package registry enabled.

  • The workflow consists on:

    • GitLab ci/cd job based on a docker container with maven
    • call to mvn deploy using a ci_settings.xml file with the token to be used
    • the pom.xml file contains the project maven repo url as specified in the documentation.
  • I attach the main pieces of the files implied on this problematic workflow using as an example the deploy token “example_deploy_token” with permissions:

read_repository, read_registry, write_registry

– gitlab-ci-yml :

 stage: deploy
 image: maven:3.8.1-openjdk-15-slim
 - 'mvn clean deploy -s ci_settings.xml -e'

– ci_settings.xml :

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">

– pom.xml :