有没有办法让 GitLab 缓存在不被写入的情况下被消耗?
Is there a way to have GitLab Cache be consumed without being written to?
我有一个 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
TLDR。不使用 path
元素覆盖 cache
。
您可能还必须向全局缓存配置中添加一个关键元素。我实际上从未在没有关键元素的情况下使用过。
查看缓存文档here
里面非常详细.gitlab-ci.yml
documentation is a reference to a cache
setting called policy
。 GitLab 缓存具有 push
(又名 write
)和 pull
(又名 read
)的概念。默认设置为 pull-push
(开头为 read
,结尾为 write
)。
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:
这几乎描述了这种情况:作业 configure
更新缓存,而 parse
作业不改变缓存。
在消耗作业中,添加:
cache:
paths:
- assets/
policy: pull
为清楚起见,在全局设置中明确说明这一点可能不会有什么坏处:
cache:
paths:
- assets/
policy: pull-push
我有一个 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
TLDR。不使用 path
元素覆盖 cache
。
您可能还必须向全局缓存配置中添加一个关键元素。我实际上从未在没有关键元素的情况下使用过。
查看缓存文档here
里面非常详细.gitlab-ci.yml
documentation is a reference to a cache
setting called policy
。 GitLab 缓存具有 push
(又名 write
)和 pull
(又名 read
)的概念。默认设置为 pull-push
(开头为 read
,结尾为 write
)。
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:
这几乎描述了这种情况:作业 configure
更新缓存,而 parse
作业不改变缓存。
在消耗作业中,添加:
cache:
paths:
- assets/
policy: pull
为清楚起见,在全局设置中明确说明这一点可能不会有什么坏处:
cache:
paths:
- assets/
policy: pull-push