Auto-merge between release branches
Bugs and security fixes often need to be added to multiple branches, either back porting fixes to old releases, or fixing an issue in
master and pending release branches that have already been branched. This can be done manually, but it is laborious and error prone. GitLab should make releasing fixes easy.
BitBucket Server (not cloud) has an automatic merge feature (docs) which will perform one merge after another from a low release branch to the next highest release branch. When a merge can't be applied cleanly (passing tests, no conflicts) the merge request must be resolve manually before more merges occur to higher numbered release branches.
Currently it is possible to implement this workflow in GitLab using a CI job. Roughly the CI job should:
- only run on branches matching the release pattern (
- calculate the next closet release branch (
- create a new branch from
- cherry pick changes from
- push, open a merge request, set to MWPS
The upside of this approach is that it is much more flexible to different workflows that may not use semver. The downside of this approach is that requires a CI job to be written by each customer.
Add a new setting Automatic branch merging with the option to:
- enable / disable
- configure the development branch (this is needed to handle the final cascading merge from
release-11-6(highest version) to
- configure which branches to include (e.g.
When enabled, and a change is pushed/merged to a branch matching the configured pattern:
- create a new merge request targeting the next highest version (as defined by semver) with the same changes
- set merge request to merge when pipeline succeeds
If the merge request merges successfully, this will trigger the next merge.
If the merge request cannot merge due to approvals, conflicts, test failures, the merge will fail awaiting manual intervention. When the problem is resolved and the merge succeeds, the next merge request will be triggered automatically.
With 8.3 releasing "Merge when build succeeds" I feel GitLab is getting close to a feature I developed using the API + Hooks within a separate side-application inspired by Atlassian-Stash's auto merge feature.
Essentially the idea is that if I have a branch setup of
(Just pretend there are branches between release/1.1-release/1.9)
If I then make a production hotfix to release/1.0, this should then attempt to auto-merge from release/1.0 all the way to develop. It's an efficient automated way to make sure hotfixes are always added to each respective release branch. Should CI Builds fail or merge conflicts occur, these would have to be solved manually of course. The way branches merge should be customizable, not enforcing the use of git flow.