Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Continuous integration and continuous delivery with git-flow

We have been doing continuous integration and continuous delivery since a while with Subversion commits as the pipelines triggers. Recently, we started using git in some projects with git-flow and we are trying to decide which of the branches of git-flow should we use to trigger the continuous integration and continous delivery pipelines.

Here are two approaches:

1. Use develop branch

Problem: With git-flow we are supposed to deploy the release (or master) branch in production, so we would have to build two different pipelines, one for continuous integration (branch develop) and one for continuous delivery (branch master). This could introduce bugs in production because the version in production will not be the same that the one in other environments (integration, test, staging).

2. Use master branch:

Problem: This way, we would not have a truly continuous integration, since changes to these branches are pushed not very frequently.

Which is the rigth branch to use in the pipelines?

like image 535
alejokf Avatar asked Sep 03 '15 23:09

alejokf


People also ask

What is Git in continuous integration?

Continuous IntegrationConsider an application that has its code stored in a Git repository in GitLab. Developers push code changes every day, multiple times a day. For every push to the repository, you can create a set of scripts to build and test your application automatically.

What is continuous delivery and continuous integration?

Continuous integration is focused on automatically building and testing code, as compared to continuous delivery, which automates the entire software release process up to production. For more information, see Practicing Continuous Integration and Continuous Delivery on AWS: Accelerating Software Delivery with DevOps .

Is Gitflow CI CD?

Git flow and CI/CD Any development team will inevitably use a delivery pipeline to integrate, build and deploy their code. More often than not, this tool will be referred to as a “CI/CD pipeline”.

Is Git a continuous integration tool?

The core pillar of a CI / CD system is the support and integration of the underlying Version Control System (VCS). The most popular VCS's are Git, Subversion, Mercurial and Perforce. cloud CI tools may offer support for some or all of these VCS's.


2 Answers

Git-flow and continous integration are, by definition, incompatible. Branches are a mechanism for delaying integration: when you commit to a branch other than master (or trunk, if you come from Subversion), you are avoiding continous integration. Doing continous integration is simple, but not easy.

like image 165
xpmatteo Avatar answered Sep 20 '22 15:09

xpmatteo


The truth lies between the two. If you want to adopt git-flow in a strict CD pipeline, you should use the release-branch for your CI:

  1. For every (batch of) develop-branch commit(s), let your CI server automatically create a release-branch and run all your tests on it.
  2. If it fails, let it report and/or delete the branch, otherwise merge it to master.

The basic idea comes from John Ferguson Smart's slide about CI/CD in Java Maven projects (BDD in Action, Jenkins Definite Guide).

like image 45
Arman Avatar answered Sep 20 '22 15:09

Arman