Search code examples
gitlabgitlab-cipipeline

Gitlab continuous integration across multiple repos


I have a project, based on buildroot, which is composed of two repos:

  1. Buildroot root, let's say project A
  2. Our packages, project B

We host a Gitlab server, and I'd like to set up a CI/CD job for the compilation.

The process I want to set up is as follow:

  • If a merge request (MR) appears on A/B -> trigger a pipeline.
  • If two MRs appears on both repos, referring the same issue, in a 15 minutes interval (this timer is to give some time to the developer to create all his MRs for his issue) -> trigger a single pipeline visible for both of the MRs.

The last point is where I struggle. Basically, what I want is to have one unique pipeline for one issue, so that if both repos have a MR for this particular issue, my pipeline would checkout on the correct branch for A and B and then launch the compilation for it.

I know I can trigger a pipeline on repo A from B, but I can't figure out how to ensure a unique pipeline will be launched if two MRs are created. Because right now, from what l can see, each MR would create it's pipeline and I'll end up with two compilations...

I've thought about using buildbot with Gitlab, but I'd prefer to stay on Gitlab only, because it's easier to maintain, than having many different tool for this.

Does anyone have ever faced this kind of problem on Gitlab and/or have a clue on how to deal with it ?

Thanks in advance!

Edit

I've come across this page which appears to be the exact solution to my problem, and unfortunately that seems not to be on the roadmap.
I'll dig into the proposition of having a meta project above A and B, because it would allow me to keep everything with Gitlab-CI, even if it means creating this project and dealing with a special process...


Solution

  • Answering my own question.

    I've been trying to build up a setup with buildbot for several days, but as I said I really don't wanna add another tool to manage (my team isn't ready for this, and buildbot does too many things that we don't need for now).

    I've come into this comment which made me chose the following approach.

             Gitlab.example.com
    A            B                              *NEW Project 'C' only for CI/CD*
    ------\/------                              ----------------\/--------------
     - Trigger C with Key for the issue X,       - Fetch/clone A and B for issue X
       unless one already exists for issue X     - Prepare the sources
     - Wait for C to finish                      - Compile
     - Report C's status (with URL to the
       corresponding Pipeline)
    

    This setup is the best I can get for a Gitlab-only solution.

    If someone's interested in the code I used, tell me and I'll post sample.