Forgive my frustration since the issue I am having is so horrible and frustrating. It seams as if no one on the Internet knows how to fix this!!
I am a new user of gitlab. The whole platform looks very promising and so I started using gitlab for my project. My project uses several maven projects and the first project is only a pom.xml file. It is a maven dependency that all my other projects use. So I want to deploy this dependency to the Package registry and then the other maven projects can use it.
For 2 days now I have been trying to get this to work and unfornately all I can say is that Gitlab is absolutely HELL!!!. I create a project and put a pom.xml in it.
In the repositories section I have this:
<repositories>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/groups/MYGROUPID/-/packages/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/groups/MYGROUPID/-/packages/maven</url>
</repository>
<snapshotRepository>
<id>gitlab-maven</id>
<url>https://gitlab.com/api/v4/groups/MYGROUPID/-/packages/maven</url>
</snapshotRepository>
</distributionManagement>
I am using the group package registry since I want all my packages in the same spot. I dont want 10 different urls for all my projects. I then create a ci_settings.xml (Why the hell can’t I just upload a settings.xml somewhere in gitlab?) I now have to change my project structure because of gitlabs failings. In the ci_settings.xml I put this:
<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>Deploy-Token</name>
<value>${env.CI_DEPLOY_TOKEN}</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
</settings>
My .gitlab_ci.yml looks like this:
image: maven:latest
variables:
MAVEN_CLI_OPTS: "-s ci_settings.xml"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
cache:
paths:
- .m2/repository/
build:
stage: build
script:
- mvn $MAVEN_CLI_OPTS compile
deploy:
stage: deploy
script:
- mvn $MAVEN_CLI_OPTS deploy
only:
- master
And then I check it all in. The pipeline runs and it doesnt work because the Deploy token is missing. I generate a group deploy token and it gives me a username and password. The deploy token in ci_settings.xml has 1 variable. The group token has 2 fields (username/Password). What do I need to fill in there???
Is thiseven the right approach? Gitlab is turning into the biggest disaster I have ever used.