How to enable maven artifact caching for gitlab ci runner?

后端 未结 8 1960
星月不相逢
星月不相逢 2020-12-12 17:14

We use gitlab ci with shared runners to do our continuous integration. For each build, the runner downloads tons of maven artifacts.

Is there a way to configure gitl

8条回答
  •  醉话见心
    2020-12-12 17:37

    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
    

提交回复
热议问题