We use gitlab ci with shared runners to do our continuous integration. For each build, the runner downloads tons of maven artifacts.
Is there a way to configure gitl
The accepted answer didn't do it for me.
As zlobster mentioned, the guys at GitLab have this amazing repository where you can find a proper example of the .gitlab-ci.yml
file used for Maven projects.
Basically, what you need are these lines:
cache:
paths:
- .m2/repository
Keep in mind that if you decide to a add a local cache for a certain job, the global one added above will be replaced. More on this here.
You can add cache folder to gitlab-ci runner configuration and pass it to maven.
/etc/gitlab-runner/config.toml
[[runners]]
...
[runners.docker]
...
volumes = ["/cache", "/.m2"]
...
.gitlab-ci.yml
variables:
MAVEN_OPTS: "-Dmaven.repo.local=/.m2"
build:
script:
- mvn package