gpt4 book ai didi

yaml - Gitlab-Ci:如何在作业之间共享数据

转载 作者:行者123 更新时间:2023-12-04 10:46:41 24 4
gpt4 key购买 nike

我想在两个作业之间共享一个文件,如果文件已更改,请对其进行修改。 python脚本将cache.json文件与更改进行比较,并有时修改cahce文件。
.gitlab-ci.yaml:

image: ubuntu

stages:
- test

cache:
key: one-cache
paths:
- cache.json

job1:
stage: test

script:
# - touch cache.json
- cat cache.json
- python3 modify_json_file.py
- cat cache.json

问题在于它在下一次作业运行时不存在 cache.json文件。我收到错误消息: cat: cache.json: No such file or directory。我也确实插入了一次touch命令,但是如果没有touch命令,则在下次运行时不会改变任何内容。

是我做错了还是不理解gitlab上的 cache错误?

最佳答案

我认为您需要工件而不是缓存。
cache vs artifact:

cache - Use for temporary storage for project dependencies. Not useful for keeping intermediate build results, like jar or apk files. Cache was designed to be used to speed up invocations of subsequent runs of a given job, by keeping things like dependencies (e.g., npm packages, Go vendor packages, etc.) so they don't have to be re-fetched from the public internet. While the cache can be abused to pass intermediate build results between stages, there may be cases where artifacts are a better fit.

artifacts - Use for stage results that will be passed between stages. Artifacts were designed to upload some compiled/generated bits of the build, and they can be fetched by any number of concurrent Runners. They are guaranteed to be available and are there to pass data between jobs. They are also exposed to be downloaded from the UI.

关于yaml - Gitlab-Ci:如何在作业之间共享数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50358923/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com