When using gitlab-ci on a java+maven project; the maven artifacts are not cached. They are getting downloaded every-time.
I have deployed the gitlab-runner as kubernetes.
And the build time logs show
Creating cache edu-erp...
.m2/repository/: found 761 matching files
No URL provided, cache will be not uploaded to shared cache server. Cache will be stored only locally.
.gitlab-ci.yml
image: maven:latest
variables:
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version"
MAVEN_OPTS: "-Djava.awt.headless=true -Dmaven.repo.local=./.m2/repository"
cache:
paths:
- ./.m2/repository
# keep cache across branch
key: "$CI_BUILD_REF_NAME"
stages:
- build
- test
build:
stage: build
cache:
key: edu-erp
paths:
- .m2
script:
- "mvn clean compile $MAVEN_CLI_OPTS"
artifacts:
paths:
- target/
test:
stage: test
cache:
key: edu-erp
script:
- "mvn test $MAVEN_CLI_OPTS"
The cache should be available across builds.