在GitLab运行器上配置缓存 [英] Configure cache on GitLab runner

查看:1242
本文介绍了在GitLab运行器上配置缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法配置缓存目录,但是以某种方式无法正常工作.我什至不确定它是否需要config.toml文件.

I don't manage to configure a cache directory, but somehow it does not work. I'm not even sure it takes the config.toml file.

我的config.toml:

my 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中

... both on /etc/gitlab-runner/config.toml and in ~/.gitlab-runner/config.toml

我的.gitlab-ci.yml:

my .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

When I try: 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存储库...

The build is successful, but the .m2 repository is not cached...

因此,我有2个问题:

  1. 如何知道gitlab-runner是否实际使用了我的config.yml?
  2. 什么是缓存的正确配置?

提前谢谢!

推荐答案

我刚才遇到了同一问题.我不确定您使用的是哪个版本的Gitlab,但是版本12支持S3兼容存储或GCS作为缓存提供程序(

I ran into the same issue just now. I am not sure which version of Gitlab you use, but version 12 supports either an S3-compatible storage or GCS as the cache provider (see thes docs), but no local cache folder like cache_dir = /tmp/gitlab-runner-cache.

我遇到的问题是,我忘记在Runner配置的[runners.cache]部分中添加Type = "s3":

The issue I had was, that I forgot to add Type = "s3" to the [runners.cache]section of the Runner configuration:

  [runners.cache]
    Type = "s3"
    Shared = true
    [runners.cache.s3]
      ServerAddress = ...

这篇关于在GitLab运行器上配置缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆