Gitlab CI allows you to define certain paths, which contain data that should be cached between builds, on a per job or build basis (see here for more details). In combination with khmarbaise’s recommendation, this can be used to cache dependencies between multiple builds.
An example that caches all job dependencies in your build:
cache:
paths:
- .m2/repository
variables:
MAVEN_OPTS: "-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository"
maven_job:
script:
- mvn clean install