【问题标题】:GitLab cache does not reliably find matching filesGitLab 缓存无法可靠地找到匹配的文件
【发布时间】:2018-03-15 11:10:20
【问题描述】:

我的gitlab CI如下:

stages:
  - test

cache:
  key: ${CI_COMMIT_SHA}
  paths:
    - mymark

test:
  stage: test
  script:
    - ls -l
    - echo "hi" > mymark
    - ls -l
  tags:
    - myrunner
  only:
    - dev

文件mymark由构建脚本创建:

$ ls -l
total 76
-rw-r--r--  1 root root    3 Mar 15 10:48 mymark

但是 GitLab 没有看到它:

Creating cache 122f151d6b0a9d37cfa2172941d642e5c48287fc...
WARNING: mymark: no matching files                 
Created cache
Job succeeded

这似乎是随机发生的:有时找到文件,有时找不到:

Creating cache 63d295dad175370aa61d13c4d2f3149e050df5e0...
mymark: found 1 matching files               
Created cache
Job succeeded

【问题讨论】:

标签: gitlab gitlab-ci gitlab-ci-runner


【解决方案1】:

这是因为cache只能用于你项目内部的文件,所以即使

cache:
  paths:
    - /my_root_path

将让 GitLab CI 查找 /home/user/yourproject/my_root_path。

【讨论】:

    【解决方案2】:

    当您在任何before_scriptscript 指令中将cd 移出原始目录时,就会发生这种情况。

    确保您 cd 回到您所在的原始目录,以便 cache 代码可以看到它正在寻找的路径。

    【讨论】:

      猜你喜欢
      • 2019-05-25
      • 1970-01-01
      • 2018-08-28
      • 1970-01-01
      • 2021-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多