Check Branch age on a Gitlab stage to enable trunk based development and CI

Check Branch age on a Gitlab stage to enable trunk based development and CI

Posted by pablo.velasquez on 19 Jul, 2019

We are believers and practitioners of the agile manifesto and we like the 9th principle which states that “Continuous attention to technical excellence and good design enhances agility”, therefore with the current state of software development for us that means Continuous Integration and as such Trunk Based Development is a specific practice that enables CI.

We use Gitlab as our tool for CI, and therefore this is one of our most visited places all day, we thought that as a help to remind the developers to keep short-lived feature branches that we could show them a warning if the branch is older than 24 hours and help them get used into planning their tasks smaller so that they can finish them in one day and not only have their code added quickly to master and tested with others code, but also achieve multiple small successes by completing planned worked and not keeping incomplete tasks open.

Note that we are not ready to commit directly to master as it would be the ideal state of trunk based development, but we use short lived branches and feature flags.

If the branch first commit is younger than 24 hours then it will show a green checkboxWe are believers and practitioners of the agile manifesto with emphasis on the 9th principle which states that “Continuous attention to technical excellence and good design enhances agility” and on the current state of software development for us that means Continuous Integration and as a specific practice Trunk Based Development is a CI enabler and at CI’s core.

We use Gitlab as our tool for CI, and therefore this is one of their most visited places all day, we thought that as a help to remind the developers to keep short-lived feature branches that we could show them a warning if the branch is older than 24 hours and help them get used into planning their tasks smaller so that they can finish them in one day and not only have their code added quickly to master and tested with others code, but also achieve multiple small successes by completing planned worked and not keeping incomplete tasks open.

Note that we are not ready to commit directly to master as it would be the ideal state of trunk based development, but we use short lived branches and feature flags.

If the branch first commit is younger than 24 hours then it will show a green checkbox

Gitlab Succesfull pipeline

But if it's not then it will display a warning, but won’t stop the pipeline

Gitlab pipeline with warnings

Here is the code:

https://gitlab.com/atlanticsoft_public_repo/gitlab_pipelines_24_hour_branch_check

enter code here

Pablo Velásquez Atlanticsoft Founder

Notes:

If interested in knowing more of trunk based development you can read more here: https://trunkbaseddevelopment.com/

We use Unleash for feature flags https://github.com/Unleash/unleash


   AGILE    TRUNK BASED DEVELOPMENT    GITLAB    CI    CONTINUOUS INTEGRATION   

 Share on: Twitter / Facebook / Google+ / Email