Only keep latest artifact of a pipeline
Related to: #241026 (closed)
If you have pipelines with multiple stages you may end up with a lot of intermediary artifacts.
As an example:
frontend -> backend -> deployment
nodejs project_1 (needs nodejs) deployment_to_servers (needs project_1 through project_4) branch: develop
project_2 (needs nodejs) deployment_package (needs project_1 through project_4) branch: master
project_3 (needs nodejs)
project_4
deployment_to_servers is just pushing all four artifacts to servers under own control.
In the case of deployment_package a zip file containing all artifacts from the previous job is created which is then handed over to an external service provider.
In case of deployment_package there are 6 artifacts some containing artifacts of previous jobs. In this case keeping only the latest artifact (the final in the pipeline) is all that is required as it contains everything, and the previous ones are just using disk space.
Also: making keep latest artifact configurable in .gitlab-ci.yml would allow to handle the different cases (see the switch in behavior in regard to the branch). This should IMHO be possible for each step