Versioning and Build Identity¶
A build has three separate identities, and each has its own source. Keeping them apart is what lets
the image tested on development be the same image that runs in production.
| Question | Answer | Where it comes from |
|---|---|---|
| Which build is this? (build identity) | The commit SHA | -Dbadger.build.sha at build time, written into the jar |
| What version do we call it? (display label) | A release such as 0.103.0, or dev 1a2b3c4d |
The BADGER_RELEASE_VERSION environment variable of the deployment |
| Which release was it? (release name) | A git tag on the released commit | Computed by dev-scripts/nextVersion.sh when a release is made |
See Release Pipeline Design for why.
Build identity¶
CI passes CI_COMMIT_SHA and CI_COMMIT_SHORT_SHA to Maven (build-scripts/build.sh); devEnv.sh
passes the checkout's HEAD. A Maven build without them reports unknown. The root pom declares
the properties (badger.build.sha, badger.build.sha.short) and everything else reads them:
messages.properties(filtered):badger.build.shais the full SHA andadmin.badger.system.versionis the short one. The second key keeps its old name because many templates use it, but it is no longer a release number.- Asset cache-busting.
AssetUrlDialectappends the short SHA as?v=when a file has no content-hashed copy. A new build changes the URL; the same image in dev and production gives the same URL. - The
menu.jsstorage key (MenuGeneratorExtension.withPlatformVersion, and the templates'data-menu-version) and the browser error beacon'sdata-release. - Spring Boot build-info (web, rest, auth): the
build.shaproperty. - The
X-Badger-Buildresponse header, on every response of web, rest and auth, set byBuildIdentityFilterbefore security and routing, so redirects and errors carry it too. It holds the full SHA. A smoke test after a deploy reads it to tell the new pods from old ones still serving during a rollout. - The
X-Badger-Releaseresponse header, beside it, holds the release label (BADGER_RELEASE_VERSION, elsedev <sha8>), so a check after a release can confirm the release name over HTTP. - The docs image serves the SHA at
/build.txt(theBUILD_SHAbuild argument).
The worker has no HTTP endpoint, so it has no header; see the gap described in the design.
The version label in the admin¶
ReleaseLabel gives the admin footer its text. With BADGER_RELEASE_VERSION set, the footer shows
that value. Without it the footer shows dev <first eight characters of the SHA>, which is what the
development environment shows. ReleaseLabelAdvice puts the label on every page model as
releaseLabel; templates read the model and never call a bean.
The variable is set in the environment's kustomization in the infrastructure repository, next to the image tags the deploy job already edits. It is display only: nothing is keyed by it, so a wrong value cannot break caching or the smoke test.
Release name¶
A release is a git tag X.Y.Z on a commit. dev-scripts/nextVersion.sh works out the next number
from the commit subjects and bodies since the last release tag reachable from the commit (see its
header and nextVersion.test.sh).
The poms and the release job¶
The checked-in poms carry the constant version 0.0.0-SNAPSHOT. Every CI build runs
mvn versions:set to the computed version, so the number in the poms is never read by anything else
(devEnv.sh, the test script and the Dockerfiles take the jar by pattern), and there is no
"bump version" commit. A local build produces 0.0.0-SNAPSHOT jars.
On master, finalise_version_update tags the pipeline's commit with the release version without
committing anything, and keeps an existing tag if the commit already has one (a rerun).
create_gitlab_release writes the release description with dev-scripts/releaseNotes.sh: the
commits since the previous release tag and the image digests maven-build recorded in images.env.
dev-scripts/releaseNotes.test.sh tests the generator against a throwaway repository.
The version Maven puts on a development build, <next>-dev.<sha8>, only names the artifacts and the
human image tag (<version>-dev.<sha8>-development). It is not shown to anyone and nothing is keyed
by it.