When using rules, also support flattened simplified includes
Problem to solve
With the introduction of the new rules for pipelines feature #27863 (closed) a lot of flexibility and features where added to how GitLab pipelines work. One 'feature' that was lost however, was to use anchors for 'changes'. Changes got absorbed into the rules mechanism. However, it doesn't seem to be possbile to generate a list of files to monitor for changes, and re-use this list all over.
.changes_docker: &docker_changes
changes:
- Dockerfile
- .dockerignore
job1:
only:
<<: *changes_docker
script: ls -l
job2:
except:
<<: *changes_docker
script: ls
The above shows a typical 'changes' example where one could have one list of files, and reuse these throughout the pipeline.
However, with rules, the syntax/usage has changed, and this does not seems to be possible any longer.
Further more, a nifty 'trick' would have been to combine the rules syntax, without changes, and only:changes. However this is not possible as it actually conflicts with 'rules' syntax.
In issue #23005 (closed) there was actually somewhat perfect solution, by allowing to anchor arrays, but those only work with 'scripts' at the moment.
So for now, I see no other way other then to copy/paste the content around a lot, which is a step backwards from the 'only:changes' anchor methodology.
Intended users
- Delaney (Development Team Lead)
- Sasha (Software Developer)
- Devon (DevOps Engineer)
- Sidney (Systems Administrator)
Proposal
I believe at the least rules:changes should also use the flattened approach, allowing us to anchor a previously generically defined array.