Skip to content

GitLab Maven Repository documentation improvements

In https://docs.gitlab.com/ee/user/project/packages/maven_repository.html there are a few placeholders in configuration files that are then replaced with a sed script:

  • 'sed -i "s/CI_JOB_TOKEN/${CI_JOB_TOKEN}/g" /root/.m2/settings.xml'
  • 'sed -i "s/PROJECT_ID/${CI_PROJECT_ID}/g" pom.xml'

Why not using environment variables directly so they are automatically replaced runtime?

Example:

<value>CI_JOB_TOKEN</value>

To:

<value>${env.CI_JOB_TOKEN}</value>

You can also abstract other data like https://gitlab.com and move it as a variable.

This would make the whole management easier and more flexible, simplifying examples.

Note: I'm not a Maven user, so maybe there are reasons to keep it as-is. Anyway, I created a working example in https://gitlab.com/gitlab-examples/multi-project-pipelines/ for other scope, but it uses GitLab Maven Repository as well.