loading...
Cover image for Check Branch age on a Gitlab stage to enable trunk based development and CI
ATLANTICSOFT

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

pablovelasquez profile image pablovelasquez Originally published at blog.atlanticsoft.us ・2 min read

This blog post was originally posted on our company blog at:
http://blog.atlanticsoft.us/page/3/check-branch-age-on-a-gitlab-stage-to-enable-trunk-based-development-and-ci/

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 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

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

Discussion

pic
Editor guide