0

I'm trying to setup a GitLab CI pipeline on a Docker runner. I have a Docker runner with a Maven image (maven:3.8.6-openjdk-11) that I'm trying to use for my pipeline that compiles a Maven project. I have set maven repository cache but I feel like this cache is not working properly. Every time my pipeline runs, it downloads the dependencies that are useful for compiling my project, onto my Nexus artifactory... I expected it to download only the "new" dependencies, and for the others, they use the cache without downloading them. Below is the content of the .gitlab-ci.yml file:

variables:
  MAVEN_OPTS: >-
    -Dhttps.protocols=TLSv1.2
    -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository
    -Dorg.slf4j.simpleLogger.showDateTime=true
    -Djava.awt.headless=true

cache:
  paths:
    - .m2/repository/

build:
  tags:
    - tdev
  script:
    - mvn --settings $MAVEN_SETTINGS clean compile

On each run it download the dependencies:

[...]
Downloading from infogreffe: https://xxxx/nexus/repository/infogreffe/org/wildfly/core/wildfly-core-security/19.0.0.Final/wildfly-core-security-19.0.0.Final.jar
Downloaded from infogreffe: https://xxxx/nexus/repository/infogreffe/org/wildfly/core/wildfly-controller-client/19.0.0.Final/wildfly-controller-client-19.0.0.Final.jar (214 kB at 70 kB/s)
Downloading from infogreffe: https://xxxx/nexus/repository/infogreffe/org/wildfly/security/wildfly-elytron-auth/2.0.0.Final/wildfly-elytron-auth-2.0.0.Final.jar
Downloaded from infogreffe: https://xxxx/nexus/repository/infogreffe/com/oracle/ojdbc5/11.2.0.2.0/ojdbc5-11.2.0.2.0.jar (2.0 MB at 666 kB/s)
[...]

Note that I use a local cache.

Thanks.

I expect that with using a cache for my maven repository, it won't try to download dependencies on every pipeline run unless there are new dependencies. But maybe I misunderstood how caching works...

Ludo06
  • 11
  • 1
  • Question title should have the core question that you want to ask. Current title describes what your question is related to but not the actual question – Dhaval D Oct 28 '22 at 08:03
  • Are you using a single runner? the cache is only local to the runner. If you have many runners then each time the job runs for the first time on that runner it will have to download everything – Chris Doyle Oct 28 '22 at 08:08
  • In my pipeline, I use a single runner and a single job. – Ludo06 Oct 28 '22 at 08:50

0 Answers0