如何解决如何在Gitlab CI的同一阶段跨作业合并工件?
在Gitlab中,CI工件是根据生成工件的工作进行隔离的,因此,在下载时,您只能按作业进行下载。
是否可以下载所有工件,或将工件传递到其他阶段并从那里上传?基本上是一种合并阶段的所有工件的方法。
可能需要的场景:假设在阶段部署中,我正在使用10个不同的并行作业在10个不同的服务器上部署我的项目。这些中的每一个都会产生一些伪像。但是,无法从用户界面下载所有内容。
那么有人知道解决方法吗?我不是在寻找基于API的解决方案,而是在基于UI或编辑CI yaml文件以使其正常工作。
解决方法
您可以在管道中创建一个“最终”(打包)阶段,该阶段使用artifacts语法将所有工件组合在一起。
例如:
stages:
- build
- package
.artifacts_template:
artifacts:
name: linux-artifact
paths:
- "*.txt"
expire_in: 5 minutes
build:linux-1:
extends: .artifacts_template
stage: build
script:
- touch hello-world-linux-1.txt
build:linux-2:
extends: .artifacts_template
stage: build
script:
- touch hello-world-linux-2.txt
build:linux-3:
extends: .artifacts_template
stage: build
script:
- touch hello-world-linux-3.txt
package:
stage: package
script:
- echo "packaging everything here"
needs:
- build:linux-1
- build:linux-2
- build:linux-3
artifacts:
name: all-artifacts
paths:
- "*.txt"
expire_in: 1 month
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。