Search code examples
gitmergegitlabproduction-environment

How to deploy from master to production with minimal effort in gitlab?


I am evaluating the possibility of production branch with Gitlab flow as given here: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/workflow/gitlab_flow.md#production-branch-with-gitlab-flow

Here are some points about our setup:

  • There are no feature branches as suggested in Gitlab Flow
  • All work is committed directly to master.
  • Each developer has his own fork which they rebase before starting off each work-item
  • Developers make frequent commits for each work item and make a merge request consisting many commits when they are done.
  • Tester pulls work from master and tests it. As a result Tester may have commits from two different merges but he may be only testing one at a time.

So lets assume I created a production branch from master a few days ago.

X1--X2--X3(master)
        |
        (prod)

After this Ann and Barry have made two merge requests which have been accepted

X1--X2--X3--A1--A1--A3-Am--B1-B2-Bm(master)
        |
        (prod)

Am and Bm represent the individual merge commits by Ann and Barry

Now tester tests and OKs Ann's changes.

Now I have to move Ann's commits to production. What would be the the neatest way? By neatest, I mean: minimum effort on part of Developer and admin. Ideally i would prefer to take Am and merge it to production, but Gitlab only gives me a cherry-pick option and not a full merge.

Like this:

X1--X2--X3--A1--A1--A3-Am--B1-B2-Bm(master)
                       |
                     (prod)

OR this

X1--X2--X3--A1--A1--A3--Am--B1-B2-Bm(master)
        |
        X3'-A1'-A1'-A3'-Am'(prod)

Now let me rewind this scenario. Tester finds a bug in Ann's code and asks for a fix. Ann does it and tester ok's the fix .

X1--X2--X3--A1--A1--A3--Am--B1--B2--Bm--A4--Am2(master)

Now I would like to take

X1--X2--X3--A1--A1--A3--Am--B1--B2--Bm--A4--Am2(master)
        |
        X3'-A1'-A1'-A3'-Am'-A4'-Am2'(prod)

Next tester OKs Barry's code so I merge Barry's changes to production

X1--X2--X3--A1--A1--A3--Am--B1--B2--Bm--A4--Am2(master)
        |
        X3'-A1'-A1'-A3'-Am'-A4'-Am2'--B1'--B2'--Bm'(prod)

Is this feasible and even practical?

What would be the best way to track pending/missing changes to production? I would like to use Gitlabs's "X commits behind master" feature to track this(eg at end of a sprint, if I'm 0 commits behind, it means I have all changes in this sprint). Or is there a better way?

Sorry if my question seems too broad but I really am confused and lost.

Appreciate any guidance that can make my life easier.


Solution

  • I had the same reflexion on gitlab prod workflow.
    It seems difficult to implement this workflow with Gitlab CE.

    I wanted to make this :

     R1-----------R2--R3
     /           /   /
    A---B---C---D---E---F ← master
                 \
                  E---F---G ← new-feature
    

    The fact is that Gitlab only allows the possibility to merge the whole branch master to prod or to cherrypick (bad idea).

    So i decide to use a (imperfect) production workflow with tags.

    R1          R2  R3   
    A---B---C---D---E---F ← master
                 \
                  E---F---G ← new-feature
    

    Hope it will help you.