Ordered stages across includes
Problem to solve
Further building on https://gitlab.com/gitlab-org/gitlab-ee/issues/12730, some customers have an interest in controlling the ordering of included stages. For example, stage(s) which must be executed before any developer-defined stages and/or stage(s) which must run after developer-defined stages.
If there are multiple includes adding
after steps, all added steps will be placed at the beginning or the end, but without a guarantee of a certain order within the including pipeline. For example, if a template has its own
a job and includes
c.yml which define stages
c respectively to be placed at the beginning, the actual order of the pipeline could be sequenced
b, c, a or
c, b, a.
To accommodate this, two keys
required_stages_after can be added which would define a list of stages that will be prepended or appended respectively to the
stages key in the resulting configuration. This allows for the addition of this feature in a backwards-compatible manner with minimal changes required.
Given the following developer-made
# some existing .gitlab-ci.yml file stages: - build - test
And an included template
required_stages_before: - compliance required_stages_after: - audit_stage
The resulting 'effective'
stages: key from the merging of these two files should be rendered as follows:
stages: - compliance - build - test - audit_stage
Permissions and Security
There are no changes to the permissions system introduced via this change.