Gitlab commit trigger another repo build

Problem to solve

We have a project that we are calling templates that contain all of our various GITLAB build definition in them, so we can control them centrally. This project has no build, as there is nothing to build, it’s just the yml definitions.

Each project repo that we want to build will have the .gitlab-ci.yml file configured like:

  - project: "smb/templates"
    ref: master
    file: "/build-types/lambda-nodejs.yml"

    INCLUDED_PATHS: "src/*"

This is working well, but the complexity of the templates repo/yml is increasing the more we add to it and it’s quite easy to make a change that impacts another build type without really knowing you are doing it.

The solution we feel for this is that we would have sample builds, the idea being that when you commit to the templates repo, it would trigger downstream repos. These downstream repos would be sample builds of each of our build types.

  • lambda nodejs
  • netcore
  • flyway
  • etc etc

These sample builds would need to use the branch that the changes to the templates repo were made in.


I’m changing code in the templates repo on the branch feature/test.
I commit this code (or this could happen on merge request)
At this point the sample builds are triggered and the templates are used from the branch feature/test.

  • What have we looked at?

As the templates repo doesn’t have a .gitlab-ci.yml we can’t use the keyword [trigger]
Even if we could trigger the samples how could we make the ref dynamic?

  - project: "smb/templates"
    ref: {branch from templates that triggered this build}
    file: "/build-types/lambda-nodejs.yml"


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

  • Self-managed
    Version 16.8