Multi project pipelines, issue with pulling other repos into my job

Hello, I’m encountering a challenge. My objective is to have my pipeline also include other repositories into the working directory. For some repositories (projects) that will never require a full pipeline, I would add a simple .gitlab-ci.yml file like this:

stages:
  - Dependencies
Push DBB:
  stage: Dependencies
  script:
  - |
    echo "Pushing repo to the filesystem"
  tags:
    - mytag
  only :
    variables:
      - $CI_PIPELINE_SOURCE == 'pipeline'

Afterward, I would call it from my main pipeline like so:

DBB:
  trigger:
    project: /aaa/dbb
    branch: main
    strategy: depend

This approach works well, as it triggers the DBB project and pushes the repository to the filesystem using my Git runner.

Now, I have other repositories that I also want to push into my working directory. However, these repositories have their own .gitlab-ci.yml files that I don’t want to execute at the moment; I only want the repository to be pushed or pulled. I thought about creating a separate configuration file in those repositories, let’s call it dependency-pipeline.yml, and populate it with:

 stages:
  - Dependencies
Push myRepo:
  stage: Dependencies
  script:
  - |
    echo "Pushing Myrepo to the filesystem"
  tags:
    - mytag

Then, I attempted to call it from my main pipeline, but I realized that the trigger keyword doesn’t provide an option to specify a different YAML file. So, I tried:

additional_repo1:
  stage: Dependencies
  trigger:
    include:
      - project: 'bbb/other-repo'
        ref: 'main'
        file: 'dependency-pipeline.yml' 

However, because it is an include , it treats it as a “child” instead of “multi-project” and from what I observe it is not pulling the other repo. It just simply runs the yml file. How can I make this work? My goal is to elegantly pull that repository into my working tree without resorting to running git commands from a script if possible."
thank you

The only way I found so far is using a variable for example “push_only : true/false” and passing it to the main pipeline of the other repository and in this other pipeline I would control ALL the jobs depending on the push_only variable.
So in every job I would add a rule
if: PUSH_ONLY != TRUE and leave only one dummy job which does really nothing besides just forcing the repo to by pushed.
So it does work although it requires additional work and doesn’t feel right in 100%

Let me know if there is a better way.

Hi, there is no other way. In multi-project pipeline you always trigger the entire project’s pipeline. If only some jobs should run, you need to set proper rules for jobs in the “other” repositories.

Thank you Balonik. I understand that in multi project-pipeline you trigger the entire pipeline but using multi-project pipeline is for me just a work around to get somehow that other repo in. I don’t have to use multi-project if there is any other decent way to get this other repo pushed (or rather pulled).

I thought I could have a script which would just run git clone using $CI variables for repo, token etc but I had some issues with it and I gave up. But perhaps it was a better way and I should keep trying that instead of doing a multi project pipeline for such a trivial task as getting another repo in. Any recommendation?
thanks

You have a GitLab Runner running on the server where you need to pull the repos? It is a “shell” executor Runner? Because you could just “git clone” the repos in the script section and copy files whenever you need.

Thank you. I will do “git clone” since there is no dedicated gitlab option for this. Actuall I will do something like "test -d name && git pull || git clone … " since it might already be there since these can be run many times.