Versioning and publishing
Version
The version is <major>.<minor>.<patch>-build.<yyMMddHHmmss> from the three klok { } version properties and a
timestamp. Which time the timestamp states depends on what the project is:
| Project type |
Timestamp |
Why |
DATAMODEL, OTHER (libraries: datamodels, the framework) |
the build time |
every main build is a release to an immutable registry and needs a version of its own |
INTEGRATION, APPLICATION (deployed as an image) |
the commit time, in UTC |
two builds of the same commit must give the same bytes, so an unchanged rebuild deploys nothing |
The build time is computed once per build and stored on the root project, so every module of a multi-module build
(the Quarkus extension's runtime and deployment, for instance) gets exactly the same version. The commit time is
CI_COMMIT_TIMESTAMP in a GitLab pipeline, else the committer date of HEAD from git log -1 in the project
directory, so another CI system or a laptop gets the same answer; without either it falls back to the build time. Either
can be fixed from outside with -PklokBuildTimestamp=<ts> or KLOK_BUILD_TIMESTAMP when two invocations must agree.
disableTimestampVersionMetadata = "true" drops the suffix for local experiments; releases always carry it.
Reproducible builds of integrations and applications
Since build-ci-templates!54 an integration is deployed by the digest of its image, so the deployment changes exactly
when the image does. kaniko builds the image reproducibly from build/quarkus-app, so the digest is only stable if
build/quarkus-app is. It was not: two ./gradlew clean quarkusBuild runs of the same commit of klok-api-odl gave
the same 308 files in lib/ but a different application jar, quarkus-run.jar and quarkus/. Every main pipeline, a
rerun of an unchanged commit and catalog included, therefore produced a new digest and restarted a service that had not
changed. Three values differed from build to build, and for a project of type INTEGRATION or APPLICATION the plugin
now fixes all three, without anything in the project's build script:
- The version carried the build time, and it is in the name of the application jar and in the Quarkus configuration.
It now carries the commit time (see above).
- The jars Gradle writes stored the time of every entry. Every archive task of the project now has
preserveFileTimestamps = false and reproducibleFileOrder = true.
- The jars Quarkus writes (
app/, quarkus-run.jar, quarkus/*.jar) stored the build time too. Whenever the
io.quarkus plugin is applied, the plugin sets the Quarkus build property quarkus.package.output-timestamp to the
commit time. A value the project sets in its own quarkus { } block wins.
With these, the same commit and catalog give byte-identical lib/, app/, quarkus-run.jar, quarkus-application.dat
and transformed-bytecode.jar, and a changed catalog or commit still gives different ones (measured on klok-api-odl,
2026-10-07, Quarkus 3.33.3.2: all 312 files identical between two builds that share the Gradle build cache; an older
klokQuarkusExtension in the catalog changed lib/ and quarkus/).
What the plugin cannot fix: quarkus/generated-bytecode.jar. Quarkus runs its build steps in parallel, and the
bytecode it records depends on the order in which they finish: the numbered proxykey constants of the recorded classes
and the order of some recorded calls change from run to run. Running the steps on one thread
(io.quarkus.builder.execution.maxPoolSize=1) deadlocks the build in Quarkus 3.33, because steps wait for work they
submit to the same pool. So a fresh Quarkus build never reproduces this one file, and the image built from it gets a new
digest. What makes it the same is not building it again: quarkusAppPartsBuild is cacheable, and with the Gradle build
cache on, an unchanged input set takes the previous output from the cache, byte for byte. The plugin's part is to make
the input set unchanged: with a build time in the version, every build was a cache miss. The integration build template
turns the build cache on (--build-cache), and the cache survives between pipelines in the project's CI cache
(.gradle/caches). The cache key contains absolute paths (Quarkus' project descriptor), so a hit needs the same build
directory, which a pipeline on the same runner has.
What the plugin does not touch. Libraries keep their release semantics: DATAMODEL and OTHER projects keep the
build time and Gradle's archive defaults. Two inputs stay outside the commit and the catalog and can still change an
integration's output: the Klok knowledge that a project with klokKnowledge=true bundles from the catalog's agents zip
records when the zip was first fetched into the Gradle cache (klok-knowledge.properties, fetchedAt), which only
changes when the cache is lost or the zip's content changes; and the image itself is built FROM a tag, so a new base
image under the same tag is a new digest (see the image build template).
Every project that applies the plugin writes build/klok-release.properties:
group=dev.klok.acme.integration
artifact=acme-egress-fortnox
version=1.0.0-build.260910120000
The shared CI job update_klok_catalog reads it after a successful publish and writes the version into the dependency
catalog (see Catalog update).
The plugin's own release goes the same way, and its build takes its Klok dependencies from that catalog. Its POM then
names the versions the catalog had at build time, so the newest POM says what the plugin was built against (Design
decisions).
Publishing
maven-publish is configured with one publication (jar, sources, javadoc unless disabled, POM with description,
license, maintainer and SCM from the extension) and one repository, JReleaserStaging, which is the local directory
build/staging-deploy. ./gradlew publish therefore uploads nothing: it stages the artifacts on disk. Running it
locally is harmless and reaches no registry.
JReleaser deploys the staged artifacts (see Release below):
- every project goes to its own GitLab package registry,
https://$CI_SERVER_HOST/api/v4/projects/$CI_PROJECT_ID/packages/maven, authenticated with CI_JOB_TOKEN; readers
resolve it through the tenant's group registry. That registry is the release the platform builds with;
- a
PUBLIC project also goes to Maven Central (Sonatype Central Portal), as a public copy that may lag behind. The CI
template sends it in maven_central_release, a job of its own that is allowed to fail, so Central never holds back the
catalog (Maven Central is optional in the CI templates' release process). Before 2026-11-12 a PUBLIC project went to
Central only.
Both need the CI environment, which is why publishing happens in the pipeline on main, never by hand.
Release
JReleaser is applied and configured from the extension: the deploy described above, from build/staging-deploy (to the
GitLab project registry, and for projectVisibility = PUBLIC also to Maven Central, with the signing key and Sonatype
credentials from the CI environment secret), and a GitLab release with a generated changelog for every version. On
main only, so a branch never publishes, the CI template runs ./gradlew publish jreleaserFullRelease --deployer=gitlab in release_and_publish_job, then ./gradlew jreleaserDeploy --deployer-name=sonatype in
maven_central_release. The Central deployer is named sonatype, and the template depends on that name: JReleaser 1.18
ignores --exclude-deployer and does not accept mavenCentral as a deployer type (Maven Central is optional in the
CI templates' release process).
The plugin's own pipeline follows the same template, and its catalog update does not wait for Central. Projects resolve
the plugin through settings.gradle, which names Maven Central and the plugin portal. In CI, klok ci maven-proxy adds
the klok group registry to pluginManagement after them, so a plugin version that is only on GitLab is found. A build
outside CI does not get that repository: it finds only the plugin versions that reached Central.
Maven Central can take 30 to 40 minutes to report a deployment as published; the release job has a 90 minute timeout and
the framework builds configure JReleaser to wait up to an hour. A retry of a release that already reached Central fails
with "already deployed" because Central is immutable, which is one more reason every main build is a new timestamped
version.
What a project must have
gradle/klok-libs.versions.toml with the klokLibs catalog (refreshed with updateKlokLibsToml).
klok { } with projectType, projectVisibility, projectDesc and the version numbers.
- In CI: the tenant CI role
<tenant>-ci in Vault (one per tenant, every project under the root group) with the
<tenant>-cicd-read policy, which gives the pipeline the registry tokens, the JReleaser secrets and the deploy key. The
build templates in build-ci-templates do the rest; every credential the plugin's tasks use (the job token for GitLab
registries, GITLAB_TOKEN, JRELEASER_*, KLOK_BROKER_AUTH_*, KLOK_INTEGRATION_CONTEXT_TOKEN) is on Authentication
in CI and deployment there (klok-docs/ci/authentication.md).