如何在 Gitlab CI 中合并同一阶段的跨作业工件?

ker*_*707 8 continuous-integration gitlab gitlab-ci devops

在 Gitlab CI 工件中,根据生成它们的作业进行隔离,因此在下载时,您只能按作业下载它。

有没有办法下载所有工件,或者将工件传递到其他阶段并从那里上传?基本上是某种合并阶段所有工件的方法。

可能需要它的场景:假设在阶段部署中,我正在使用 10 个不同的并行作业在 10 个不同的服务器上部署我的项目。其中每一个都会生成一些工件。但是,无法从用户界面下载所有这些内容。

那么有人知道解决方法吗?我不是在寻找基于 API 的解决方案,而是在寻找基于 UI 的解决方案或编辑 CI yaml 文件以使其工作。

Rek*_*vni 10

您可以在管道中创建一个“最终”(包)阶段,使用工件语法将所有工件组合在一起。

例如:

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
Run Code Online (Sandbox Code Playgroud)