gpt4 book ai didi

gitlab-ci.yml、before_script 和 artifact

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

gitlab-ci.yml documentation ,它说

before_script is used to define the command that should be run before all jobs, including deploy jobs, but after the restoration of artifacts.



这告诉我 Artifact 是在作业开始运行之前生成的

但是 artifact documentation

Artifacts is a list of files and directories which are attached to a job after it completes successfully



这告诉我 Artifact 是在作业完成运行后产生的。

这是一个矛盾。有人可以解释一下这不是矛盾吗?

我想他们在谈论以前工作中的神器?但我不知道 artifact 和 job 是如何工作的,并且可能是错误的。

最佳答案

Artifact 可以由一个阶段的构建作业产生,并由下一阶段的构建作业消耗。因此 before_script 在为当前阶段恢复前一阶段产生的 Artifact 之后运行。

所以下面的 .gitlab-ci.yml

stages:
- build
- test

before_script:
- echo "before_script"
- ls

build_artifacts:
stage: build
tags:
- docker
script:
- echo "build_artifacts"
- touch build_output
artifacts:
paths:
- build_output

test_artifacts:
stage: test
tags:
- docker
script:
- echo "test_artifacts"

将给出以下输出:
# build_artifacts job
$ echo "before_script"
before_script
$ ls
README.md
$ echo "build_artifacts"
build_artifacts
$ touch build_output
Uploading artifacts...
build_output: found 1 matching files
Uploading artifacts to coordinator... ok id=56026 responseStatus=201 Created token=xxxxzzzz
Job succeeded



# test_artifacts job
Downloading artifacts for build_artifacts (56026)...
Downloading artifacts from coordinator... ok id=56026 responseStatus=200 OK token=xxxxzzzz
$ echo "before_script"
before_script
$ ls
README.md
build_output
$ echo "test_artifacts"
test_artifacts
Job succeeded

如您所见,test_artifacts 作业会在 before_script 之前下载 Artifact 。运行。

关于gitlab-ci.yml、before_script 和 artifact,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52730919/

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