Image Tagging

Tagging Images by Branch, Commit and Build Number

A tag should answer "what is this image?" without a lookup. The Inspect stage asks the library's imageTag() (Writing a Global Pipeline Step) for one that combines all three coordinates, and reuses it as the Compose 514 project name:

The tag and the Compose project, set in the Inspect stage (excerpt)Groovy
        seedCheck()
        script {
          env.TAG = imageTag()
          env.COMPOSE_PROJECT_NAME = "l2-ci-${env.TAG}"
        }

main-e2d7a8a-5 reads as branch main, commit e2d7a8a, build 5: the branch groups images by line of development, the commit ties the image to its source, and the build number keeps a rebuilt commit's tag unique. The Push stage adds a moving tag, main. After two builds, the registry holds:

The tags of booknest-api in the local registryShell
curl -s -u "booknest:$(cat ~/v5-ch5/.secrets/registry-pass)" \
  http://localhost:32550/v2/booknest-api/tags/list
Output
{"name":"booknest-api","tags":["main","main-65a7671-4","main-e2d7a8a-5"]}

Deploy by the immutable tag or, better, the digest; the moving tag is for people (Tagging Conventions). Other branches' images are built and tested but never pushed.