Chronological Build Naming

Mark Hayford
2 min readSep 16, 2019

--

TLDR: Use the command date +%s to get a value that increases based on time. Example in a docker build you could tag an image with the date.

Export TagChronoValue = $(date +%s)
docker build -t $TagChronoValue .
##The time in something more readable might be nice
Export TagChronoValue = $(date +%m-%d-%Y_%H:%M:%S)

This would give you a tag that increments based on the time.

A friend mentioned to me that using something random in a build or a name kind of sucks when trying to figure out when it came from. And version numbers are not always great because how often do you really increase those? Source control commit numbers or pull requests are not the worst, but don’t really give you an idea of when it happened. He suggested a chronological value because, it always changes, when you do it from the epoch time it always goes up, and it can give a clear idea of when the build happened.

In docker you could add multiple tags and the commit hash is another useful one. And Maybe a better one for some situations.

git log -1 --pretty=%H##Outputs something like 18101e645ee3d9b1de302164bb31f907a8282349

Outside of docker you could tag the file name with both, you could use a smaller hash and a smaller timestamp. Lots of options. I hadn’t heard of using a chronological value and it made sense to me because hashes are not something worth trying to remember.

--

--

Mark Hayford
Mark Hayford

Written by Mark Hayford

A fuzzy life. Fuzzy computer problems. fuzzy Dog friends. fuzzy thoughts.

No responses yet