Consider this of .gitlab-ci.yml
:
variables:
MAVEN_OPTS: "-Dmaven.repo.local=/root/.m2/repository"
cache:
key: "M2"
paths:
- /root/.m2/repository
This works correctly when running directly in gitlab, but it doesn't work locally when running as:
gitlab-runner exec docker test
If I run it locally like this, I can see messages like Successfully extracted cache
, but then it re-downloads all the maven dependencies, which in my case meaning downloading hundreds of megabytes.
I cannot see the difference between running it locally and remotely, both of them should work the same I guess?
Where is this cache stored? Can I somehow verify there is actually something stored?
As in this issue, you need to put your m2 cache folder into a volume, or the container would start from scratch (empty cache) every time, promting maven to download everything all over again.
That issue also reports, instead of using volumes:
But using a volume remains the most portable solution: