Make it easy for includes to add jobs at beginning/end of pipeline
Problem to solve
A common use case for includes is to want to position something at the beginning or end, but as the author of a shared include you don't necessarily know what the first or last stages will be called. This makes it difficult and error prone to try to write a job that runs at the start or end of a pipeline.
Intended users
Authors of includes
Further details
This solution came from discussions around https://gitlab.com/gitlab-org/gitlab-ee/issues/29980, which would make it possible to merge stages across includes. That ended up being a very hard problem to solve in an easy to use way, and we discovered this solution which was simpler and addressed most of the use cases. A new issue was opened because this one does not solve the exact same problem as the other.
Proposal
We will add two new pre-defined stages called .pre and .post These would exist alongside the other predefined stages, build, test, deploy, and would be sequenced as follows:
- .pre
- build
- test
- deploy
- .post
.pre would always be guaranteed to be the first stage, and .:post:. would always be guaranteed to be the last.
If you write a job in your include that needs to run at the beginning, you'd insert it as follows:
my_job:
  stage: .preAny other includes that also need to run at the beginning would use this pre-defined .pre stage, and all of these would run in parallel. .post is used and works the same, but is always at the end of the pipeline.
Permissions and Security
Not applicable