为何即使CI管道中的缓存已经可用,也要创建它?

时间:2020-04-15 08:39:54

标签: caching continuous-integration gitlab gitlab-ci gitlab-ci-runner

我在Gitlab中有一条CI管道,其中的纱线依存关系被缓存和重用。缓存工作正常,但是在管道结束时,在完成所有作业之后,将重新创建缓存。有人知道为什么这样做吗?以及如何配置CI以便不执行此操作?

我在Mac OS上使用本地运行器。但是,当我使用来自Gitlab的共享运行程序时,也会遇到这种情况。

我注意到,尽管分支的名称为“ configuration-1”,但缓存的创建名称为“ configuration-ci-1”。

在CI配置.yml下面:

# Node version. 
image: node:latest

# Cache config
cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - node_modules/
    - .yarn-cache

# Install dependencies if not available
before_script:  
  - yarn install --frozen-lockfile --cache-folder .yarn-cache --prefer-offline

# Specify the stages
stages:
  - build
  - staging
  - production

Build:
  stage: build
  tags:
    - local
    - node
  script:
    - yarn run build

以及在管道末尾有关创建缓存的输出:

Running after_script
00:01
Saving cache
01:48
 Creating cache configuration-ci-1...
 node_modules/: found 140250 matching files         
 .yarn-cache: found 143125 matching files           
 No URL provided, cache will be not uploaded to shared cache server. Cache will be stored only locally. 
 Created cache
Uploading artifacts for successful job
00:02
 Job succeeded

感谢您的反馈!

0 个答案:

没有答案