'".gitlab-ci.yml": how to define multiple projects in "trigger"?

I have a project "my_project_0" that must trigger pipelines of all my other projects ("my_project_1", "my_project_2", etc.).

What I want:

  stage: multi_project_test
  trigger:
    project: "my_project_1"
    strategy: depend
  trigger:
    project: "my_project_2"
    strategy: depend
  trigger:
    project: "my_project_3"
    strategy: depend

...but I have the error Key 'trigger' is duplicated.

The official page about Multi-project pipelines is useless because it has no examples for multi-projects pipelines (only for a parent-child trigger).

What is the correct syntax to trigger pipelines of multiple projects?



Solution 1:[1]

You'll have to create a bridge job for each downstream pipeline you want to trigger.

For example:

downstream 1/3:
  stage: multi_project_test
  trigger:
    project: project-1
    strategy: depend

downstream 2/3:
  stage: multi_project_test
  trigger:
    project: project-2
    strategy: depend

downstream 3/3:
  stage: multi_project_test
  trigger:
    project: project-3
    strategy: depend

I haven't tested this, but you should be able to use parallel:matrix to define the same thing as above in a concise manner:

downstream_pipelines:
  stage: multi_project_test
  parallel:
    matrix:
      - DOWNSTREAM_PROJECT: ["project-1", "project-2", "project-3"]
  trigger:
    project: $DOWNSTREAM_PROJECT
    strategy: depend

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sytech