Cross repository merge request failure

Problem to solve

I have 2 repositories A and B. When a Merge Request passes on repository A, I push some changes to repository B, and automatically create a Merge Request.

What I would like to have is: if the Merge Request in repository B fails, mark the Merge Request on repository A as failed. Which would prevent merging A until the job on B is a success

Note: this is not a Merge Request dependency, as I do not want to block MR on A until MR on B is merged. I want MR on A to fail if any job on B fails

Versions

Please select whether options apply, and add the version information.

  • Self-managed
  • GitLab.com SaaS
  • Dedicated
  • Self-hosted Runners

Hi, Merge request by definition can’t fail , so I assume you mean that when the pipeline fails on project B, you want to fail the Pipeline on project A. We have out of the box features for this flow called Multi project pipeline and parent child pipeline. see the docs page for it Downstream pipelines | GitLab. You will need to use the strategy:depend to create dependency between the pipelines.

Ok thx, but if I understand the docs correctly, I need to add in project A in the .gitalb-ci.yml a job that will trigger the pipeline on project B, and set strategy: depend on it.

However, project B pipeline gets triggered because a job in project A pushes changes to project B, then creates a Merge Request. So it is automatic. So to make this work, I would have to trigger the pipeline a second time?

Example project A:

a-job:
  script:
    - echo "test" > test.txt
    - git add . && git commit "test" && git push projectB/test-branch

project B:

b-job:
  script:
    - do something that might fail

To make strategy:depend work here, I would have to add this to project A?

trigger-B:
  trigger:
    project: projectB
    branch: test-branch
    strategy: depend

So what would happen is the pipeline would be triggered from the push in a-job, then again from trigger-B? or maybe I would need to set something manual to avoid the double trigger?