I am very new to GitLab and am testing the Maven repository feature. I have a simple Maven project, which produces a JAR, which I would like uploaded to the Maven Artifact Repo in GitLab. I have followed this guide as carefully as I can: https://docs.gitlab.com/ee/user/project/packages/maven_repository.html and I also followed portions of this guide: https://docs.gitlab.com/ee/ci/examples/artifactory_and_gitlab/
Thanks in advance for any help!
Problem 1: Local Deploy
When I run âmvn deployâ on my local machine, I get the error below labeled âLocal Error Messageâ (Access Denied). Iâm guessing that either I donât have my permissions configured properly, or the path is bad. I have updated my local ~/.m2/settings.xml with a Private Token (per the guide above with =gitlab-maven). I have âMaintainerâ permissions on the Project that Iâm building. Is 'Maintainer" able to perform the deploy action? I canât find any documentation about permissions in relation to this. The group/project are still in the GitLab trial period.
The Private Token I generated only had API selected. Is that right? I named the token âgitlab-mavenâ, assuming the name is arbitrary. Is that right?
I have configured the POM and nodes exactly as described in the guide, replacing the PROJECT_ID with my project ID and matching all nodes to my ~/.m2/settings.xml (gitlab-maven).
Problem 2 : CI Deploy
I have also run this build and deploy via the GitLab CI. The deploy step also results in Access Denied. I have placed the full error below labeled âGitLab CI Error Messageâ. For the CI build, I have in the root of the project the file /.m2/settings.xml with a Job-Token, with the value â${env.CI_JOB_TOKEN}â. Iâm assuming that this token is available in the environment at build time and that I donât need to do anything to generate it and I donât have to replace that variable. Is my understanding of Job-Token correct?
I copied and pasted the .gitlab-ci.yml to run the build/deploy from this tutorial: https://docs.gitlab.com/ee/ci/examples/artifactory_and_gitlab/#configure-gitlab-cicd-for-simple-maven-dep
Both errors (local and CI) list the path: https://gitlab.com/api/v4/projects/9660882/packages/maven/apps4work/co.a4w.api/1.0-SNAPSHOT/maven-metadata.xml
I donât believe this path should exist yet, as I have not pushed the artifact into the Maven package repository.
=== Local Error Message ===
[ ERROR ] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project co.a4w.api: Failed to retrieve remote metadata apps4work:co.a4w.api:1.0-SNAPSHOT/maven-metadata.xml: Could not transfer metadata apps4work:co.a4w.api:1.0-SNAPSHOT/maven-metadata.xml from/to gitlab-maven (https://gitlab.com/api/v4/projects/9660882/packages/maven): Access denied to: https://gitlab.com/api/v4/projects/9660882/packages/maven/apps4work/co.a4w.api/1.0-SNAPSHOT/maven-metadata.xml
org.apache.maven.lifecycle.LifecycleExecutionException : Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project co.a4w.api: Failed to retrieve remote metadata apps4work:co.a4w.api:1.0-SNAPSHOT/maven-metadata.xml: Could not transfer metadata apps4work:co.a4w.api:1.0-SNAPSHOT/maven-metadata.xml from/to gitlab-maven (https://gitlab.com/api/v4/projects/9660882/packages/maven): Access denied to: https://gitlab.com/api/v4/projects/9660882/packages/maven/apps4work/co.a4w.api/1.0-SNAPSHOT/maven-metadata.xml
=== GitLab CI Error Message ===
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project co.a4w.api: Failed to retrieve remote metadata apps4work:co.a4w.api:1.0-SNAPSHOT/maven-metadata.xml: Could not transfer metadata apps4work:co.a4w.api:1.0-SNAPSHOT/maven-metadata.xml from/to gitlab-maven (https://gitlab.com/api/v4/projects/9660882/packages/maven): Access denied to: https://gitlab.com/api/v4/projects/9660882/packages/maven/apps4work/co.a4w.api/1.0-SNAPSHOT/maven-metadata.xml