Gitlab: How to call child pipelines residing in different project from different upstream projects with artifacts

Problem Statement:

I have a requirement to call child pipeline from different upstream projects by also passing artifacts from upstream pipelines. Example:

project A → .gitlab-ci.yml

stages:
 build
 test

build
 stage: build
 script:
 - touch artifactA.txt
 artifacts:
  paths:
 - artifactA.txt

test
 stage: test
 # do something here to call project C pipeline residing in different project which tests artifacts from build job

project B → .gitlab-ci.yml

stages:
 build
 test

build
 stage: build
 script:
 - touch artifactB.txt
 artifacts:
  paths:
 - artifactB.txt

test
 stage: test
 # do something here to call child pipeline residing in different project which tests artifacts from build job

project C → .gitlab-ci.yml

stages:
 test

test
 stage: test
 # do something here which accepts artifacts from upstream pipeline when triggered and runs tests against it.
   needs:
    - project: specify list of upstream projects here which can trigger this pipeline
      ref: integration-test-pipeline
      job: build
      artifacts: true

Tried few different ways by referring to gitlab docs by using needs , trigger , dependencies keywords and their variations but nothing worked so far. As a last resort I can try the API way but would rather prefer if something is already built into gitlab for such a use case.

Hi @Mrunal.Gosar

needs:project is only available in paid tiers. Do you have active GitLab subscription?

Yes I have paid subscription, but gitlab agents are in-house.

In that case it should work like you set it up, with one small difference and that you have to add an entry for each job.

project C → .gitlab-ci.yml

stages:
  - test

test:
  stage: test
  # do something here which accepts artifacts from upstream pipeline when triggered and runs tests against it.
  script:
    - ls
  needs:
    - project: my/group/projectA
      ref: integration-test-pipeline
      job: build
      artifacts: true
    - project: my/group/projectB
      ref: integration-test-pipeline
      job: build
      artifacts: true

But then does it not mean that project C will have hard dependency on project A AND project B, I want to have OR (Optional) dependency. Also I have observed 1 thing that project C pipeline does not waits till project A or project B pipeline produces the artifact

needs:project does not create hard dependency and it does not wait for the upstream jobs to finish, you have to ensure that (for example by using stages). This behavior and limits are described in the docs (link in my first reply).