I have several maven projects (not multi-modules), that are residing in GitLab. I like to setup the GitLab CI for these projects, so I looked at gitlab-ci.yml files on how to do this.
I found https://docs.gitlab.com/ee/ci/examples/artifactory_and_gitlab, which describes to put the settings.xml
in the project itself and then referr it in the gitlab-ci file.
But I was wondering, how this is done when having multiple projects that would need this settings.xml
, as putting it multiple times in the repository seems bad.
Locally I have it in my .m2 directory, but how and where to put it on the gitlab server for the pipeline ?
I mount the host volume via the config.toml
as the following example: -
concurrent = 1
check_interval = 30
[[runners]]
name = "some-name"
url = "url/to/gitlab/"
token = "some-token"
executor = "docker"
[runners.docker]
tls_verify = false
image = "some-maven-image"
privileged = false
disable_cache = false
volumes = ["...", "path/to/host/dir:/some/name:rw"]
pull_policy = "if-not-present"
shm_size = 0
[runners.cache]
While the path/to/host/dir
is a path on host machine which contains many files including with settings.xml
, settings-security.xml
and so on, based on project requirement. On the other hand the /some/name
is a directory inside the docker.
At the .gitlab-ci.yml
, I provide the before_script
as the following example: -
before_script:
- cp -f /some/name/settings.xml $HOME/.m2/settings.xml
- cp -f /some/name/settings-security.xml $HOME/.m2/settings-security.xml
- ...
after_script:
- rm -f $HOME/.m2/settings.xml
- rm -f $HOME/.m2/settings-security.xml
- ...
Please visit Advanced configuration for further information about the config.toml
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With