我无法配置缓存目录,但是以某种方式无法正常工作。我什至不确定它是否需要config.toml文件。
我的config.toml:
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
cache_dir = /tmp/gitlab-runner-cache
...在/etc/gitlab-runner/config.toml和〜/ .gitlab-runner / config.toml中
我的.gitlab-ci.yml:
image: docker:latest
services:
- docker:dind
cache:
key: "myCache"
paths:
- ${CI_PROJECT_DIR]/.m2/
variables:
DOCKER_DRIVER: overlay
MAVEN_OPTS: -Dmaven.repo.local=${CI_PROJECT_DIR}/.m2
stages:
- build
- acceptance
maven-build:
image: maven:3.3-jdk-8
stage: build
script: "mvn clean package"
artifacts:
paths:
- target/*.jar
maven-acceptance:
dependencies:
- maven-build
image: maven:3.3-jdk-8
stage: acceptance
script: "mvn verify"
当我尝试时: gitlab-runner exec shell maven-build
我得到了错误:
ERROR: Could not create cache adapter error=cache factory not found: factory for cache adapter "" was not registered
构建成功,但是未缓存.m2存储库...
因此,我有2个问题:
谢谢!
答案 0 :(得分:0)
我刚才遇到了同样的问题。我不确定您使用的是哪个版本的Gitlab,但是版本12支持S3兼容存储或GCS作为缓存提供程序(see thes docs),但没有像cache_dir = /tmp/gitlab-runner-cache
这样的本地缓存文件夹。
我遇到的问题是,我忘记在Runner配置的Type = "s3"
部分中添加[runners.cache]
:
[runners.cache]
Type = "s3"
Shared = true
[runners.cache.s3]
ServerAddress = ...