如何在同一阶段同时运行 的运行 用户之间共享缓存

How to share cache between runners that run concurrently in the same stage

我是 gitlab 的新手 CI,我正在尝试使用管道并尝试从头开始为 webapp 创建一个管道。

我有一个在管道第一阶段创建的缓存(基于 yarn.lock 的典型 npm 缓存)。

  cache:
    key:
      files:
        - yarn.lock
    paths:
      - node_modules
  only:
    refs:
      - merge_requests
      - master
    changes:
      - yarn.lock

在第二阶段,我 运行 build & test 同时执行任务。

当只有一个任务处于第二阶段(构建或测试)时,将使用相同的 运行ner runner-4qsydtwu-project-2077-concurrent-0 并重复使用缓存。

但是,当构建和测试任务同时执行时,runner-4qsydtwu-project-2077-concurrent-1用于第二个任务,缓存不可用。

如何让 运行ner *-1 重用缓存?

取自Caching in GitLab CI/CD: Good caching practices:

For runners to work with caches efficiently, you must do one of the following:

  • Use a single runner for all your jobs.
  • Use multiple runners that have distributed caching, where the cache is stored in S3 buckets. Shared runners on GitLab.com behave this way. These runners can be in autoscale mode, but they don’t have to be.
  • Use multiple runners with the same architecture and have these runners share a common network-mounted directory to store the cache. This directory should use NFS or something similar. These runners must be in autoscale mode.

因此,如果您想使用多个跑步者,您可以在选项 2 和 3 之间进行选择。