首页 新闻 会员 周边

gitlab-ci cache 无法正常工作

0
悬赏园豆:30 [已解决问题] 解决于 2022-12-07 23:08

在一个 job 中产生的 cache 文件,在另外一个 job 中却读取不到。

执行 job 的控制台日志已经显示成功创建 cache

Creating cache npm-11...
src/ClientApp/.npm/: found 7125 matching files and directories 
src/ClientApp/node_modules/: found 125151 matching files and directories
Created cache

另外一个 job 已成功加载了 cache

Checking cache for npm-11...
No URL provided, cache will not be downloaded from shared cache server. Instead a local version of cache will be extracted. 
Successfully extracted cache

但是 cache 对应的 .npm 与 node_modules 文件夹却不存在。

与 stackoverflow 上的这个问题 Why does GitLab Ci not find my cached folder? 现象一样,但不同的是,我们的 gitlab-runner 就一台服务器,2个 job 用的是同一个 docker runner。

请问如何解决这个问题?

dudu的主页 dudu | 高人七级 | 园豆:31003
提问于:2022-12-07 21:56
< >
分享
最佳答案
0

终于解决了!在看到 stackoverflow 上的 How the gitlab-ci cache is working on docker runner? what is /cache directory? what is cache_dir? 时恍然大悟。

是 gitlab-runner 的 /etc/gitlab-runner/config.toml/ -> [runners.docker] -> volumes 中的 /cache 被删除引起的

[[runners]]
  [runners.docker]
    volumes = ["/cache"]
dudu | 高人七级 |园豆:31003 | 2022-12-07 23:07
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册