Skip to content

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, https://gitlab.com/yorickpeterse/yorickpeterse.com/merge_requests/1 was deployed to my website well over a year ago, but GitLab shows it as being deployed three weeks ago:

Screenshot_from_2019-09-23_16-35-42

When recording a deployment, we need to persist the links between MRs and deployments explicitly. For this to work, we need roughly the following:

  1. 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.
  2. 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)

Development log

Status

Decisions

  • We decided to put this feature under feature flag deployment_merge_requests
  • We decided to only store that information on the DB. No API, no frontend for now

The next iteration

  • Add API support for retrieving merge requests deployed in a deployment - #35739 (closed)
  • Add UI support for displaying merge requests deployed in a deployment - #35741
  • Linking merge requests to deployments may lead to duplicate key errors when changing the status back and forth to success - #35646

This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.

Edited by 🤖 GitLab Bot 🤖