Caching 具有多条路径的GitLab CI缓存似乎跳过了一条路径

Caching 具有多条路径的GitLab CI缓存似乎跳过了一条路径,caching,gitlab,gitlab-ci,gitlab-ci-runner,Caching,Gitlab,Gitlab Ci,Gitlab Ci Runner,我正在配置一个gitlab CI,其中我在安装阶段有两个作业将依赖项拉入缓存位置。然后,处于不同阶段的作业尝试访问这些位置,但似乎只有一个位置存在 我根据Gitlab提供的python示例构建了CI,可以在这里找到 我的.gitlab-ci.yml文件如下所示 --- cache: paths: - foo-1 - foo-2 stages: - install - test install_foo-1_dependencies: stage: install scri

我正在配置一个gitlab CI,其中我在安装阶段有两个作业将依赖项拉入缓存位置。然后,处于不同阶段的作业尝试访问这些位置,但似乎只有一个位置存在

我根据Gitlab提供的python示例构建了CI,可以在这里找到

我的.gitlab-ci.yml文件如下所示

---

cache:
  paths:
  - foo-1
  - foo-2

stages:
- install
- test

install_foo-1_dependencies:
  stage: install
  script:
  - pull foo-1 dependencies

install_foo-2_dependencies:
  stage: install
  script:
  - pull foo-2 dependencies
  tags:
  - ansible-f5-runner

test_dependencies:
  stage: test
  script: 
  - ls foo-1
  - ls foo-2
install_foo-1_dependencies和install_foo-2_dependencies的输出清楚地显示了正在创建的缓存。但是,当您查看test_依赖项的输出时,似乎只创建了foo-1缓存

安装\u foo-1 \u依赖项输出:

Fetching changes...
Removing foo-1/
Checking cache for default-5...
Successfully extracted cache
Creating cache default-5...
....
foo-1: found 1000 matching files                     
Created cache
Fetching changes...
Removing installed-roles/
Checking cache for default-5...
Successfully extracted cache
Creating cache default-5...  
....                 
foo-2: found 1000 matching files        
Created cache
安装\u foo-2 \u依赖项输出:

Fetching changes...
Removing foo-1/
Checking cache for default-5...
Successfully extracted cache
Creating cache default-5...
....
foo-1: found 1000 matching files                     
Created cache
Fetching changes...
Removing installed-roles/
Checking cache for default-5...
Successfully extracted cache
Creating cache default-5...  
....                 
foo-2: found 1000 matching files        
Created cache
测试依赖项的输出

Fetching changes...
Removing foo-1/
Checking cache for default-5...
....
Successfully extracted cache
$ ls foo-1
files
$ ls foo-2
ls: cannot access foo-2: No such file or directory

您需要确保此管道的每个阶段使用相同的流道。从:

提示:对管道使用相同的运行程序,是在一个阶段或管道中缓存文件,并以保证的方式将此缓存传递给后续阶段或管道的最简单、最有效的方法

从.gitlab-ci.yml文件中看不出您是否确保每个阶段都由同一名跑步者完成。同样,为了确保使用一个流道,您应该使用以下一种或多种方法:

标记跑步者并对共享其缓存的作业使用标记。 使用仅对特定项目可用的粘性流道。 使用适合您工作流程的密钥,例如每个分支上的不同缓存。