So I have a pipeline that builds docker images to be used later by other parts of the pipeline. I have set things up so this image-building part of the pipeline only triggers if special tags are included in the commit message, to avoid rebuilding them unless necessary. But there are quite a few images and now I m trying to figure out how to make this even more fine-grained so that I can rebuild just some images when required.
Here s the idea. In my gitlab-ci.yml there is:
build-base:
stage: build-images
extends: .template_build_image
variables:
IMAGE_NAME: base
rules:
- if: $CI_COMMIT_MESSAGE =~ /^.*[build-images].*$/s
build-environment:
stage: build-images
needs: [build-base]
extends: .template_build_image
variables:
IMAGE_NAME: environment
rules:
- !reference [build-base, rules]
...
<and others>
I can add more rules for more tags easily enough, like make a rule for build-environment
to add it to the pipeline if [build-environment]
is in the commit message. My problem is that build-environment
needs build-base
. I.e. gitlab will complain if I try to run build-environment
without build-base
in the pipeline. And I don t want to remove these needs
relationships because when I am running the whole pipeline those relationships are important. I just want to selectively ignore them sometimes when I "manually" want to skip some initial steps in the pipeline (and just use the e.g. base
image already in my image registry).
Is there some way to achieve this in gitlab CI?