When there’s an image declared at the top level of .gitlab-ci.ymland inside an included file, the one in .gitlab-ci.yml is used. This is unexpected. I’d expect includes to be considered as an inner scope, and anything declared in the inner scope should override anything declared in the outer scope.
Using docker image sha256:467492ebb5e298dbc5f85fe4d168b427ad87a6bea70414521710b47c26b17f13 for nixos/nix:2.11.1 with digest nixos/nix@sha256:d8c6b97091d6944dd773c3c239899af047077dbf5411ef229bb50e5b21404b0d ...
Horrible hack workaround: copy every top-level setting inside every job in .gitlab-ci.yml, to avoid the possibility of breaking included jobs.
If the image is set as default image for the whole pipeline, the include cannot be used in pipelines that define an own default image.
While merging all contents to a full .gitlab-ci-yml GitLab just follows the rules you can see in many tools which use configuration stored in different levels. Let’s compare your case with the image to git config to have an example what I mean.
The image definition within a job in your .gitlab-ci.yml would be like setting a config for the run of one git command git -c foo=bar <rest of git command>.
The image definition within the .gitlab-ci.yml in your project is like git config --local foo bar.
The image definition in /templates/renovate-dind.gitlab-ci.yml (your include) is like git config --global foo bar
The image definition within the config of your runner is like git config --system foo bar
command > local > global > system
So if you set an own image in your .gitlab-ci.yml it overrides the value set by the include and also the image defined by the runner configuration. The same applies for defining an image within a job.
Very nice explanation, thank you! The definition of local and global are opposite of what I’d expect (.gitlab-ci.yml is the top-level file, after all, and having each include be a “global” configuration could get very messy). However, it’s clear that with the current implementation the fix needs to be implemented in Renovate, so I’ve filed an issue.