I am facing an issue when trying to publish an artifact in private gitlab repository. I am using maven and I authenticated using personal access token. When I run mvn deploy -s ~/.m2/settings.xml
I get the following error Failed to deploy artifacts: Could not transfer artifact ... 401 Unauthorized
My settings.xml file looks like this.
<servers>
<server>
<id>gitlab-maven</id>
<configuration>
<httpHeaders>
<property>
<name>personal-token</name>
<value>mytoken</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
I've also tried changing it to
<servers>
<server>
<id>gitlab-maven</id>
<username>username</username>
<password>pass</password>
</server>
</servers>
but that didn't help. And here is my pom
publishing part
<repositories>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.mycompany.com/api/v4/projects/92/packages/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.mycompany.com/api/v4/projects/92/packages/maven</url>
</repository>
<snapshotRepository>
<id>gitlab-maven</id>
<url>https://gitlab.mycompany.com/api/v4/projects/92/packages/maven</url>
</snapshotRepository>
</distributionManagement>
Is there anything that I'm missing? Thank you in advance.
Fixed this by changing property in the settings file to Private-Token
(I was using actual name of the token previously)