Merge Pipeline can't execute included jobs

Given the following .gitlab-ci.yml definition:

---
stages:
  - split

ci-build:
  stage: split
  trigger:
    include: "/includes/ci.yml"
    strategy: depend
  rules:
    - if: '$MODE != "A"'

other-build:
  stage: split
  trigger:
    include: "/includes/other.yml"
    strategy: depend
  rules:
    - if: '$MODE == "A"'

merge-build:
  stage: split
  trigger:
    include: "/includes/merge.yml"
    strategy: depend
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"

build:
  stage: split
  script:
    - echo "Hello World"

In main branch or other branches, the pipeline run as expected (see the pipeline result of my sample project). If a merge request pipeline is started, the single jobs could not be found because of the error message job failed - (downstream pipeline can not be created. No stages / jobs for this pipeline) (see also the pipeline result in my sample project).

Is it possible, that includes doesn’t work with merge pipeline per definition? What could be an alternative for that? I’m glad to hear some tips and hints from you.

I’m seeing a similar issue.

In my case, we have a job included that works. However, another included job does not. The one that does not looks very similar to yours, namely the strategy:depend part…

included_job:
  needs: [previous_job]
  variables:
    PARENT_PIPELINE_ID: $CI_PIPELINE_ID
  trigger:
    include:
    - project: 'another/project'
      file: included-ci.yml
    strategy:
      depend

I’m curious if the strategy is part of the problem, though I haven’t seen any reason why it would be.

1 Like

I found a solution here: Dynamic pipelines doesn't work when `only:` field is set (#276179) · Issues · GitLab.org / GitLab · GitLab

I’m far from a GitLab CI expert, but I believe the issue is with how parent-child pipelines work with merge request pipelines.

Specifically in my case, the trigger is causing this behavior, because it was within a merge request pipeline. My job being triggered did not have any rules associating it with a merge request pipeline, so it couldn’t run.

My solution for now is to include the relevant CI file at the top level:

include:
- project: 'another/project'
  file: included-ci.yml

And then pull its script into my job via extends:

dependency_scan_shared:
  needs: [previous_job]
  variables:
    PARENT_PIPELINE_ID: $CI_PIPELINE_ID
  extends: .included_script
1 Like

Thanks for your hint. The link to the merge child pipeline helps me find a solution. I adjust my parent pipeline with special jobs for the merge request case. The whole solution can be found in my Gitlab project Sandra Parsick / gitlab-ci-includes · GitLab