Skip to content

Multi-project builds from within a gitlab-runner?

Hi team,

I'd like to understand if it's possible to "link" project builds in GitLab CI builds. For example, in one of my projects, the build script attempts to fetch other projects which may compose a sort of integration test of sorts - more than one project is getting built. Truthfully, the other "projects" are tiny helper repos designed to isolate and avoid the "monorepo" problem, but also to keep each repo more single-purpose and mirror a bit of microservice separation of code.

One potential way I could get around this is to create a machine GitLab account on the runner machine, and grant that machine user fetch-only access to certain repos as needed. But, I wonder, if the runner itself can obtain credentials to fetch a project, and another project is also allowed to be fetched by the same runner (let's call it "shared project builds?" perhaps), it might be as easy as a checkbox in the UI given that the runner itself has special permissions to fetch the repository - why not allow it to also have permission to fetch other ones too?

I can do funky things like set ENV variables with the contents of a private SSH key, dump that variable into a file, call ssh-add, then do a git clone on the repository I want to retrieve; but all of that seems so hacky when the repo I want to clone is practically sitting next to the one being tested on the same GitLab server and runner.

Other funky things possible: I could leave artifacts around from the other repositories' builds on the same build machine, and sort of "hope" to orchestrate them all to play nicely, but that really violates the notion of having an almost-fresh environment every build-run.

Thoughts?