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 :
deploy_stage:
stage: deploy
image: maven:3.8.1-openjdk-15-slim
script:
- '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">
<localRepository/>
<interactiveMode/>
<offline/>
<pluginGroups/>
<servers>
<server>
<id>uib-gitlab-maven</id>
<configuration>
<httpHeaders>
<property>
<name>Deploy-Token</name>
<value>example_deploy_token</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
<mirrors/>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>
– pom.xml :
<repositories>
<repository>
<id>uib-gitlab-maven</id>
<url>https://git.app.uib.no/api/v4/projects/1719/packages/maven</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>uib-gitlab-maven</id>
<url>https://git.app.uib.no/api/v4/projects/1719/packages/maven</url>
</repository>
<snapshotRepository>
<id>uib-gitlab-maven</id>
<url>https://git.app.uib.no/api/v4/projects/1719/packages/maven</url>
</snapshotRepository>
</distributionManagement>
Greetings,
Carlos