I\'m building android on Gitlab CI and downloading dependencies each time is annoying. I tried caching:
$HOME/.gradle/
$HOME/.gradle/caches/
$GRADLE_HOME/cac
According to Kamil Trzciński
We run the caching outside the build container. So you can cache absolute paths, but since only /builds and /cache is transferred you have no-way to cache container-local files.
That means you need to put the gradle files into e.g. the /cache
folder
before_script:
- export GRADLE_USER_HOME=cache/.gradle
...
cache:
key: "$CI_COMMIT_REF_NAME" #optional: per branch caching, can be omitted
paths:
- $GRADLE_USER_HOME/caches/
- $GRADLE_USER_HOME/wrapper/
- $GRADLE_USER_HOME/build-cache/
The /cache
folder will be kept automatically, but I keep the cache config for clarity.