How to ensure the child branches are always up-to-date with their parent one
From the example above, when
feature
branch is merged todevelop
branch thendev
branch need to be updated to get latest code fromdevelop
so it will get no conflict or perform test with integration code when it's merged back todevelop
. Same behavior forintegrate
branchHere is the
.pre
job in gitlab pipeline to ensure this
stages:
- build
- deploy
ancestor_develop:
stage: .pre
script:
- git merge-base --is-ancestor origin/develop HEAD || ( echo "Branch is not an ancestor of develop"; /bin/false )
only:
refs:
- dev
- feature
- integrate
tags:
- ancestor-check
compile_code:
stage: build
script:
- echo build image
only:
refs:
- dev
- feature
- integrate
tags:
- runner-build
deploy_test:
stage: deploy
script:
- echo Deploy to test env
only:
refs:
- dev
- feature
- integrate
tags:
- runner-deploy
-
.pre
is highest priority stage in gitlab pipeline, it must be passed in order to continue other stages (build and deploy) - Ref: git-merge-base(1) Manual Page
--is-ancestor
Check if the first is an ancestor of the second , and exit with status 0 if true, or with status 1 if not. Errors are signaled by a non-zero status that is not 1.
Top comments (0)