GitLab将变量从一个管道传递到另一个管道

时间:2020-01-16 11:29:03

标签: variables gitlab gitlab-ci pipeline artifact

我们有一个主管道,它负责触发来自多个项目的管道并执行一些步骤。我想将文件从第一个管道输出传递到第二个管道,但是我无法这样做。

image:
  name: some-image
  entrypoint: [""]

variables:

stages:
  - create_file
  - print_file
  - consume_file

create_file:
  stage: create_file
  variables:
  trigger:
    project: user-name/project-name
    strategy: depend


print_file:
  stage: print_file
  script:
    - sleep 5
    - cat output_file.txt
  dependencies:
    - create_file

consume_file:
  stage: consume_file
  variables:
  trigger:
    project: user-name/project-name-alternate
    strategy: depend

我不想诉诸脚本而不是触发器。已经尝试过工件等,但是我找不到将它们传递到下一个管道的方法。

P.s。这只是管道中的一个样本,有多个管道取决于第一个管道的输出。

1 个答案:

答案 0 :(得分:1)

由于可以在阶段之间传递工件,因此您可以尝试将变量写入JSON等文件中,然后在另一个作业中进行解析。