continuous-integration - 有没有办法让 GitLab 缓存在不被写入的情况下被使用?

标签 continuous-integration gitlab-ci-runner continuous-delivery

我有一个 gitlab 作业,它下载一堆依赖项并将它们填充到缓存中(如果需要),然后我有一堆使用该缓存的作业。我注意到在消耗作业结束时,他们花费了大量时间创建新的缓存,即使他们没有对其进行任何更改。

是否可以让他们只充当消费者?只读?

cache:
  paths:
    - assets/
configure:
  stage: .pre
  script:
    - conda env update --prefix ./assets/env/base -f ./environment.yml; 
    - source activate ./assets/env/base 
    - bash ./download.sh
parse1:
  stage: build
  script:
    - source activate ./assets/env/base;
    - ./build.sh -b test -s 2
  artifacts:
    paths:
      - build
parse2:
  stage: build
  script:
    - source activate ./assets/env/base;
    - ./build.sh -b test -s 2
  artifacts:
    paths:
      - build

最佳答案

深深地埋在非常详细的.gitlab-ci.yml中文档是对名为 policycache 设置的引用。 。 GitLab 缓存具有push(又名write)和pull(又名read)的概念。默认情况下,它设置为pull-push(在开头读取在结尾写入)。

If you know the job does not alter the cached files, you can skip the upload step by setting policy: pull in the job specification. Typically, this would be twinned with an ordinary cache job at an earlier stage to ensure the cache is updated from time to time:

.gitlab-ci.yml > cache:policy

这几乎描述了这种情况:作业configure更新缓存,而parse作业不改变缓存。

在消费作业中,添加:

cache:
  paths:
    - assets/
  policy: pull

为了清楚起见,在全局设置中明确这一点可能不会有什么坏处:

cache:
  paths:
    - assets/
  policy: pull-push

关于continuous-integration - 有没有办法让 GitLab 缓存在不被写入的情况下被使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62366523/

相关文章:

ios - 如何使用 Xcode5 机器人查看测试覆盖率?

svn - 使用 SVN(或 git)自动提交文件修改?

docker - gitlab ci 自定义运行程序失败

jenkins - 如何在 Jenkins 中获取管道作业的 URL

java - 优化持续部署(通过责任链取消)

visual-studio-2010 - 如何配置 TeamCity 以构建包含 2 个项目的解决方案?

.net - msbuild 和文件版本更改

docker - 将 GitLab 运行程序与 GitLab 连接时出现问题

docker - CI上kubectl在交互模式下运行失败

Jenkins 管道手动步骤权限