I have done thru where do bug fixes go in git flow and the git flow and github flow pages.
There are scenarios many times when we need to show demo of new functionality and on same day fix issues of prod. So for a few hours have one branch in QA and for a few hours another.
Or pushing to beta/ UAT we want to test in staging/ QA env. But our pipeline auto builds master branch push.
Wanted to know what others do? Do you pause the pipeline's trigger and have a parameterised pipeline so that you can trigger it manually and specify the branch that you want it to use?
This is not about git flow as it is about automation, testng and devops process to acheive this.
4 Answers 4
Yeah, although the hotfix itself will be merged back into master at some point, unless you have multiple, or spin up on demand test/QA environments, you will need to switch your CI/CD pipeline around a bit.
I keep the deployment step manual rather than triggering automatically. Unless you are super confident in your super ninja trunk based mono repo CD pipeline, its nice to have a human pulling the trigger on deploys.
This gives you an intercept point where you can say... you know what, actually deploy this branch build, thanks.
Hopefully your approval/audit stuff is still there and people are actually checking to make sure this isn't abused to deploy feature branches to live without testing etc.
But you know... try it occasionally to see if they are
-
3Many CI/CD solutions allow you to specify approvers for deploying to each environment. This helps prevent people from circumventing process and paperwork.Greg Burghardt– Greg Burghardt03/17/2023 00:26:44Commented Mar 17, 2023 at 0:26
This is not about git flow as it is about automation, testng and devops process to acheive this.
You say that but the reason why you are having this problem is a Git Flow-specific assumption about "production":
But our pipeline auto builds master branch push.
From the article:
Therefore, each time when changes are merged back into
master
, this is a new production release by definition. We tend to be very strict at this, so that theoretically, we could use a Git hook script to automatically build and roll-out our software to our production servers everytime there was a commit onmaster
.
Helpfully the article likes using "per definition" (italic theirs) so there can be no confusion about what the current "production release" is. And you seem to be following that.
So you cannot just use a "always build master
automatically" rule as
the only way to deploy. You need more.
- You cannot use that rule for staging and QA since that would mean that building for QA would make a new production release (by definition)
- You probably also don’t want to make a merge to
master
(and hence make a new version release) just for a demo
You need some extra flexibility.
If you want to stick to some branch rules for deployment then you need to make some new branches:
QA
- Or
QA/dave
,QA/philip
, etc.
- Or
demo
- Or
demo/susans-showcase
,demo/carls-weekly-hangout
,demo/for-finicky-customer-X
- Or
merge --no-ff
from develop
into those optional.
For Git Flow specifically, the following practice works well most of the time:
release
branch is always deployed to QA.- Any time
master
is updated,hotfix
is automatically updated withgit merge --ff-only origin/master
. The only time that fails is if ahotfix
is pending and hasn't been merged intomaster
yet. - This is the key point: When a
hotfix
is pending, mergehotfix
intorelease
. Then you perform step #1 (release
is deployed to QA) and then QA contains both therelease
and thehotfix
. - Validate the hotfix change on QA.
- Merge
hotfix
intomaster
and deploymaster
to Prod. - Optional: merge
master
intorelease
with--no-ff
. This is optional because it won't bring in any changes, but will instead bring in just the latest merge commit onmaster
, which your pipeline might depend on for confirming yourrelease
branch is fully ahead ofmaster
before deploying to Prod.
The reason the first sentence says this works "most of the time", is every once in a while the hotfix is to fix something that a new feature replaces, in which case you wouldn't be able to test both the hotfix and the new feature simultaneously in the merged release
branch. In my experience this is rare though.
Side Note: You mentioned GitHub Flow as well, and in that case, either QA is currently vetting the new master
branch, or it's vetting some feature branch. If it's master
, presumably your release cycle is fast enough that you can treat the hotfix as a regular feature- just merge into master
and update QA with the new master
. If it's a feature branch, then the workflow is identical to what you do in Git Flow above. (Just create a second feature branch off of master
and merge that into the feature branch which is being vetted on QA, etc.)
! Deploying and testing a hotfix repo branch in different environments can vary depending on the Git Flow variant being used. Here are some general steps that can be followed for two popular Git Flow variants: Git Flow and GitHub Flow.
Git Flow Variant Deploying a Hotfix Branch Create a new hotfix branch from the production branch. Make the necessary changes to the hotfix branch. Test the hotfix branch locally to ensure that the changes work as intended. Merge the hotfix branch into the production branch. Deploy the production branch to the production environment. Testing a Hotfix Branch Create a new hotfix branch from the production branch. Make the necessary changes to the hotfix branch. Test the hotfix branch locally to ensure that the changes work as intended. Merge the hotfix branch into the production branch. Deploy the production branch to a staging environment. Test the changes in the staging environment to ensure that they work as intended. If the changes pass the tests in the staging environment, deploy the production branch to the production environment. GitHub Flow Variant Deploying a Hotfix Branch Create a new hotfix branch from the main branch. Make the necessary changes to the hotfix branch. Test the hotfix branch locally to ensure that the changes work as intended. Merge the hotfix branch into the main branch. Deploy the main branch to the production environment. Testing a Hotfix Branch Create a new hotfix branch from the main branch. Make the necessary changes to the hotfix branch. Test the hotfix branch locally to ensure that the changes work as intended. Merge the hotfix branch into the main branch. Deploy the main branch to a staging environment
-
hi thank you for your answer, but my question was not about the brancing but about the pipelines and automation. softwareengineering.stackexchange.com/a/444528/86679 is closer answer to my questiontgkprog– tgkprog03/17/2023 17:56:02Commented Mar 17, 2023 at 17:56
-
What sources did you base this answer on?Guildenstern– Guildenstern05/02/2023 19:58:20Commented May 2, 2023 at 19:58
Explore related questions
See similar questions with these tags.