Reputation: 86627
I'm trying to public a test project to its repository, but receiving a 403 FORBIDDEN
. What could be the problem?
.gitlab-ci.yml
:
image: maven:3.8.4-eclipse-temurin-11
deploy:
stage: deploy
script: mvn deploy -s ci_settings.xml
ci_settings.xml
:
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<servers>
<server>
<id>gitlab-maven</id>
<configuration>
<httpHeaders>
<property>
<name>Job-Token</name>
<value>${CI_JOB_TOKEN}</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
</settings>
pom.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.group</groupId>
<artifactId>my-commons</artifactId>
<version>1.0.0</version>
<repositories>
<repository>
<id>gitlab-maven</id>
<url>${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>gitlab-maven</id>
<url>${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven</url>
</repository>
<snapshotRepository>
<id>gitlab-maven</id>
<url>${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven</url>
</snapshotRepository>
</distributionManagement>
</project>
Result.
[INFO] Uploading to gitlab-maven: https://my.company.com/api/v4/projects/295/packages/maven/com/example/my-test/1.0.0/my-commons-1.0.0.pom
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project my-commons: Failed to deploy artifacts: Could not transfer artifact com.example:my-commons:jar:1.0.0 from/to gitlab-maven: authorization failed for https://my.company.com/api/v4/projects/295/packages/maven/com/example/my-test/1.0.0/my-commons-1.0.0.jar, status: 403 Forbidden -> [Help 1]
Upvotes: 1
Views: 2007
Reputation: 86627
The Repository section was not enabled for the project:
Settings > General > Visibility, project features, permissions > Packages > Check!
Upvotes: 6