Dependency in private package registry: Could not find artifact

Hello, community.

I have a Maven package registry hosted in a project that belongs to a group.
In that registry I manually uploaded an artifact (pom and jar files) using a personal access token.

I have a project that uses that artifact from that package registry. So, when I try to execute the test stage, it fails with this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.1.2:get (default-cli) on project docker_receiver: Couldn't download artifact: org.eclipse.aether.resolution.DependencyResolutionException: Could not find artifact transparent_coach:maven_registry:jar:1.0.0 in gitlab-maven (https://gitlab.com/api/v4/projects/23241686/packages/maven)

This is the test stage I am running:

test:
  stage: test
  allow_failure: false
  tags:
    - docker
    - dind
  script:
    - mvn --version
    - echo "$TC_GITLAB_AUTH_SETTINGS" > settings.xml
    - mvn dependency:get -Dartifact=transparent_coach:maven_registry:1.0.0
    - mvn clean verify

The settings.xml file is present and it contains the correct structure with the same personal token I used for uploading the artifact to the registry. Parameters for the registry and the artifact in pom.xml are correct.

What am I doing wrong here?

2 Likes

I have the same problem atm. What i found out so far is the fact that the dependency is build the wrong way. In your case `transparent_coach:maven_registry:jar:1.0.0 won’t work, but I bet transparent_coach:maven_registry:1.0.0:jar would.
Since some time has passed, have you managed to find a solution?

Cheers

Just to leave it here for the next person that has trouble with this:
In the end I found out that the authentication needed to be done first. It is simply the wrong error message. Make sure you have ci_settings.xml in your project that you use for your mvn commands with -s ci_settings.xml.

2 Likes

Thank you so much @stepotronic !! I have been battling this for the past 2 hours :S
I wonder if we can suggest this to be added to the documentation or something.

2 Likes

Thank you @stepotronic. for example, what i did in gitlab-ci.yml:

test-job:
  stage: test
  script:
    - 'mvn $MAVEN_CLI_OPTS test -s ci_settings.xml'