Explicitly persist the link between merge requests and deployments
When a deployments is triggered, no data is saved to link a deployments to a merge request. Instead, when viewing a merge request we go through commits and their builds to determine when the last deploy took place. As a result, deployments are not always displayed (e.g. if the commit has
ci skip in it). New deployments will also "overwrite" the deployments statues of old merge requests. For example, yorickpeterse/yorickpeterse.com!1 (merged) was deployed to my website well over a year ago, but GitLab shows it as being deployed three weeks ago:
When recording a deployment, we need to persist the links between MRs and deployments explicitly. For this to work, we need roughly the following:
- A table to persist these links in. For every merge request in a deployment this table will have a row, containing the merge request ID and the deployment ID.
- A procedure for retrieving the merge requests merged into the default branch, and have not yet been deployed to the target environment. For more info on why this approach is needed, refer to the discussion in gitlab-com/gl-infra/delivery#477 (comment 218228639)
We decided to put this feature under feature flag
- We decided to only store that information on the DB. No API, no frontend for now