Skip to content

Auto-merging renovatebot Merge Requests

This page contains a brief explanation of automerge and describes how renovatebot and triagebot work together to allow automerge to happen.

A referesher on automerge

Renovatebot has a feature called automerge. This feature allows you to selectively choose Merge Requests (MRs) which renovatebot will try to merge by itself if other MR checks pass. Note that MR checks are in place to ensure that before mergine the CI pipeline must success, there are no merge conflicts, the MR is not marked as draft, etc. Most importantly MRs must be approved by someone other than the author before merging. We discuss how this happens automatically below.

When renovatebot wants to mark a MR as eligible for automerge, it does the equivalent of clicking the Set to auto-merge button in the GitLab UI. In that sense automerge is no scarier than clicking that button and clicking that button is a common occurrence in our teams.

Automerge is enabled in renovatebot by setting the automerge configuration option in renovate.json. This can be limited to subsets of MRs in the usual fashion. For example, to limit automerge to MRs which only refresh lockfiles, add the following configuration:

{
  "lockFileMaintenance": {
    "automerge": true
  }
}

Check the renovate presets

Renovate ships with a large number of presets which can be included in configuration via the extends array in renovate.json. For example the :automergeMinor preset will enable automerge only for minor changes.

A refresher on triagebot

We run an instance of GitLab's triage bot for DevOps use. By adding a configuration policy to our GitLab bot project you can automate various tasks in GitLab issues and merge requests.

The automerge process

As noted above, when configured to do so renovatebot will use GitLab's automerge feature with MRs it considers suitable. While the majority of MR checks are fully automated there is one which still requires a human: approval. Without someone other than renovatebot approving the MRs they will not merge.

We get around this by having triagebot acting as a basic reviewer. If triagebot sees a MR opened by renovatebot which has been set by renovatebot to auto-merge, triagebot will approve the MR. Note that other checks still have to happen. For example, a MR will not auto-merge if the CI pipeline fails. The usual GitLab approver logic still applies; if someone pushes changes to the MR then triagebot's approval will be dismissed. Triagebot will also not approve a renovatebot MR if someone other than renovatebot sets it to automerge.

There is a window of time between renovatebot opening a MR and triagebot noticing the MR and approving. If in that time you want to cancel auto-merge, click the Cancel auto-merge button next to Set by uis-devops-renovatebot to be merged automatically when all merge checks pass.

See also