nix-gitlab-ci/docs/multi_pipeline.md
technofab cf80010d07 docs: write docs & improve tooling
Squashed commit of the following:

commit 86eadd3ec42b7bce0dc5716d65798af95d0d8cbc
Author: technofab <admin@technofab.de>
Date:   Fri May 2 17:10:33 2025 +0200

docs(README): fix built with nix badge

commit f50057da69e89974f17bc37b5e140b2ef9f817f6
Author: technofab <admin@technofab.de>
Date:   Fri May 2 16:09:00 2025 +0200

ci: change back rule so docs only get deployed on main

commit ce02b043f4bd83c36285e5620e71701fc3bcc998
Author: technofab <admin@technofab.de>
Date:   Fri May 2 16:08:10 2025 +0200

docs: write docs and improve formatter etc.

commit e996b23cf877d8021759b782aa5996f5e2bf12ac
Author: technofab <admin@technofab.de>
Date:   Fri May 2 16:07:56 2025 +0200

docs: update README

commit 650f97b5608c32cf6cf66cc3fdd0965dc42e4860
Author: technofab <admin@technofab.de>
Date:   Wed Apr 23 21:05:14 2025 +0200

docs: add favicon

commit 67e1bfecbcaf0b8f7dad2eecfaccf774cc560874
Author: technofab <admin@technofab.de>
Date:   Wed Apr 23 20:53:44 2025 +0200

docs: initial setup
2025-05-02 17:30:53 +02:00

1.2 KiB

Multiple Pipelines

With V2, Nix GitLab CI can generate different pipelines, depending on the pipeline source ($CI_PIPELINE_SOURCE).

By default, no matter which source, the default pipeline is built and ran. $NIX_CI_PIPELINE can override that, eg. when manually triggering a run. To configure which source should be 1-to-1 translated to a pipeline with the same name, set $NIX_CI_DEFAULT_SOURCES to a regex which explicitly does not match these sources. Or set it to an impossible to match regex, then it will always run the pipeline named after $CI_PIPELINE_SOURCE.

Example 1: always run default

If you only have a single pipeline, you just have to call it default. Everything else works out of the box.

Example 2: default and merge_request_event

If you want the source merge_request_event to trigger a different pipeline, name it like that and set $NIX_CI_DEFAULT_SOURCES to ^(merge_request_event)$. Now a merge request will run this pipeline, while everything else runs default.

Example 3: default, push and web

Set $NIX_CI_DEFAULT_SOURCES to ^(push|web)$.

Example 4: always run the specific pipelines, never default

Set $NIX_CI_DEFAULT_SOURCES to any regex that never matches the sources, like a\A or nothing.