Optionally autogenerate stage names for DAG jobs
Problem to solve
People want to be able to define
needs relationships and let GitLab figure out what stages are needed and even what they should be called. Right now, though, the
stage value is required and if none is provided it results in an error.
This also helps with some cases (but not all) where you might want to have a job that refers to another job in the same stage (#30632). If you want to do that so that you don't have to make lots of arbitrary stages, then for that case this issue will help as GitLab will handle it for you.
User experience goal
Easier to set up DAG pipelines when you don't really care about defining specific stage names.
We will allow for defining a job that uses
needs and does not have a
stage defined. In this case, the name of the virtual stage will be auto-generated.
a: needs:  image: alpine script: ... b: needs: [ a ] image: alpine script: ...
In the above example no stages are defined anywhere in the two jobs, so job a will end up in one stage and job b will end up in another one. None needed to be explicitly defined.
As far as autogenerated names, if all the needed jobs have a common prefix (i.e., rspec-) then the stage name will use that prefix in the stage name plus an incrementing number. If there is no common prefix,
needs- plus an incrementing number will be used.
All jobs that have the exact same set of dependencies should end up in a single autogenerated stage together.
Future improvements could be:
stage: prefix: buildto hint what stage names should be generated to make it convenient for users to annotate them
- Visually present all stages in a same bucket if they are in form of
build::, kind of similarly to how we group similar jobs (aka.