Access denied fetching maven package
Summary
Fetching deployed maven packages (jar or war) gives an access denied. My settings.xml looks like:
<?xml version="1.0"?>
<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 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>gitlab-maven</id>
<configuration>
<httpHeaders>
<property>
<name>Private-Token</name>
<value>PRIVATE_ACCESS_TOKEN</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
</settings>
De PRIVATE_ACCESS_TOKEN has all the possible rights and is created for a non 2fa user. The user of the token has a developer role for the project.
De war file is deployed with the following configuration in the pom.xml
<repositories>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.HOST.nl/api/v4/packages/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.HOST.nl/api/v4/projects/PROJECT_ID/packages/maven</url>
</repository>
<snapshotRepository>
<id>gitlab-maven</id>
<url>https://gitlab.HOST.nl/api/v4/projects/PROJECT_ID/packages/maven</url>
</snapshotRepository>
</distributionManagement>
Steps to reproduce
- Create an internal project in an internal nested group
- Deploy with
mvn deploy
- Verify that package is indeed in the package page of the project.
- Fetch the package with:
mvn dependency:get -Dartifact=nl.awesomegroup:projectbar:jar:0.0.1-SNAPSHOT -DremoteRepositories=gitlab-maven::default::https://gitlab.HOST.nl/api/v4/packages/maven
I'm not familiar with maven fetching mechanics but the errors shows it tries to fetch a non existing pom file.
Example Project
n/a
What is the current bug behavior?
Gives an access denied error
What is the expected correct behavior?
It should download the jar/war
Relevant logs and/or screenshots
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< nl.awesomegroup:projectbar >--------------------------
[INFO] Building awesomegroup_projectbar 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:3.1.1:get (default-cli) @ projectbar ---
[INFO] Resolving nl.awesomegroup:projectbar:0.0.1-SNAPSHOT:jar with transitive dependencies
Downloading from gitlab-maven: https://gitlab.HOST.nl/api/v4/packages/maven/nl/awesomegroup/projectbar/jar/projectbar-jar.pom
Downloading from central: https://repo.maven.apache.org/maven2/nl/awesomegroup/projectbar/jar/projectbar-jar.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.585 s
[INFO] Finished at: 2019-07-23T10:05:57+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get (default-cli) on project projectbar: Couldn't download artifact: org.eclipse.aether.resolution.DependencyResolutionException: Failed to read artifact descriptor for nl.awesomegroup:projectbar:0.0.1-SNAPSHOT:jar: Could not transfer artifact nl.awesomegroup:projectbar:pom:jar from/to gitlab-maven (https://gitlab.HOST.nl/api/v4/packages/maven): Access denied to: https://gitlab.HOST.nl/api/v4/packages/maven/nl/awesomegroup/projectbar/jar/projectbar-jar.pom -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Output of checks
n/a
Results of GitLab environment info
System information
System: Ubuntu 16.04
Proxy: no
Current User: git
Using RVM: no
Ruby Version: 2.6.3p62
Gem Version: 2.7.9
Bundler Version:1.17.3
Rake Version: 12.3.2
Redis Version: 3.2.12
Git Version: 2.21.0
Sidekiq Version:5.2.7
Go Version: unknown
GitLab information
Version: 12.0.3-ee
Revision: 1b1872f9d93
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 9.6.11
URL: https://gitlab.HOST.nl
HTTP Clone URL: https://gitlab.HOST.nl/some-group/some-project.git
SSH Clone URL: git@gitlab.HOST.nl:some-group/some-project.git
Elasticsearch: no
Geo: no
Using LDAP: no
Using Omniauth: yes
Omniauth Providers: crowd, google_oauth2
GitLab Shell
Version: 9.3.0
Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories
GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
n/a
Possible fixes
(If you can, link to the line of code that might be responsible for the problem)
Edited by Pouja Nikray