Reputation: 1631
I'm trying to use the caching mechanism but it doesn't work, I have tried different attempt but none of them seems to work for me. The listed tasks take about both about 75sec on my machine and on gitlab ci about 5-6 Minutes where the runner is downloading the dependencies again and in every pipeline.
The question is how can I cache the downloaded deps with gitlab ci?
image: dockerregistry.my-image:1.0.0
variables:
GIT_SUBMODULE_STRATEGY: normal
GRADLE_USER_HOME: $CI_PROJECT_DIR/.gradle
cache:
paths:
- .gradle/wrapper
- .gradle/caches
before_script:
- echo `pwd`
- echo `$CI_PROJECT_DIR`
- rm -f .gradle/caches/modules-2/modules-2.lock
- rm -fr .gradle/caches/*/plugin-resolution/
build:
stage: build
script:
- ./gradlew assemble
junit:
stage: test
script:
- ./gradlew test
thanks
Executor: Kubernetes
Gitlab Version: 11.0.x
Submodule path 'my-other-application': checked out 'fxxxx1'
Checking cache for default...
Successfully extracted cache
.........
Running after script...
$ echo "End CI"
End CI
Creating cache default...
.gradle/wrapper: found 222 matching files
.gradle/caches: found 8474 matching files
Upvotes: 2
Views: 4283
Reputation: 338
I'm using docker executor with this and is working:
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
With docker the cache is stored in the container, so if i run something like docker system prune
and clear not running containers the cache is lost.
I don't know how Kubernetes works, maybe the container get deleted at the end of execution.
-> https://gitlab.com/gitlab-org/gitlab-runner/issues/1906
Upvotes: 1