Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Environment Variables

Status: 🟢 The variables below are set during builds. 🟡 KARGO_JOBS is set, but describes no limit the build itself observes. ⚪ Variables marked planned depend on features that are not built yet (workspaces, flavors reaching the build path).

Kargo exports a standard set of variables to compiler invocations, hooks, and plugins, so a script never has to be told where it is or what it is building.

Package

VariableExampleStatus
KARGO_MANIFEST_DIR/home/jane/my-app🟢
KARGO_PKG_NAMEmy-app🟢
KARGO_PKG_VERSION1.2.0🟢
KARGO_PKG_VERSION_MAJOR1🟢
KARGO_PKG_VERSION_MINOR2🟢
KARGO_PKG_VERSION_PATCH0🟢
KARGO_PKG_AUTHORSJane Doe <jane@example.com>🟢
KARGO_PKG_DESCRIPTIONOrder processing service🟢
KARGO_PKG_REPOSITORYhttps://github.com/example/my-app🟢

The split version components save a script from parsing semver to stamp a build number or compute a Docker tag.

Build context

VariableExampleStatus
KARGO_BUILD_DIR/home/jane/my-app/build🟢
KARGO_TARGETjvm🟢
KARGO_PROFILErelease🟢
KARGO_JOBS8🟡
KARGO_KOTLIN_VERSION2.4.21🟢
KARGO_TOOLCHAIN_DIR~/.kargo/toolchains/kotlin-2.4.21🟢
KARGO_CACHE_DIR~/.kargo/cache⚪

KARGO_TOOLCHAIN_DIR is how a hook reaches kotlinc or kotlin-daemon-client without guessing a path or depending on a global install.

KARGO_JOBS is [build] jobs passed through verbatim, and that is all it is: nothing in Kargo runs concurrently because of it, so it is a number a hook can read rather than a budget a hook is sharing. Sizing your own parallelism to it is choosing that number yourself — which is reasonable, since it defaults to the core count, but it is not coordination. It does not bound downloads either; those have a limit of their own.

Flavors and variants

Set when flavors are configured. ⚪ Flavors do not reach the build path yet, so these are not populated today.

VariableExample
KARGO_VARIANTpaid-production-release
KARGO_FLAVOR_<DIMENSION>KARGO_FLAVOR_TIER=paid
KARGO_BUILD_CONFIG_<KEY>KARGO_BUILD_CONFIG_API_URL=https://api.example.com

Dimension names are upper-cased: dimension tier becomes KARGO_FLAVOR_TIER. Every build-config entry is exported with a KARGO_BUILD_CONFIG_ prefix, so a deploy script can read the same API URL the application was compiled with.

Workspaces

Status: ⚪ Planned — depends on workspace orchestration.

VariableExample
KARGO_WORKSPACE_DIR/home/jane/my-workspace
KARGO_WORKSPACE_MEMBERshared

Variables from .kargo.env

Every entry in .kargo.env is exported to builds, hooks, and plugins, and is available for ${env:…} interpolation in the manifest.

# .kargo.env
DEPLOY_TARGET=staging
[hooks]
post-build = ["./scripts/deploy.sh"]
#!/usr/bin/env bash
echo "Deploying $KARGO_PKG_NAME $KARGO_PKG_VERSION to $DEPLOY_TARGET"
echo "Artifacts in $KARGO_BUILD_DIR/$KARGO_TARGET/$KARGO_PROFILE/output"

Variables Kargo reads

Alongside what it exports, Kargo honors these from your environment:

VariableUsed for
JAVA_HOMEJDK discovery
ANDROID_HOME, ANDROID_SDK_ROOTAndroid SDK discovery
KARGO_HOMEOverrides ~/.kargo — useful in CI where only project paths are cached
NO_COLORDisables colored output
RUST_LOGVerbosity of internal tracing output, for debugging Kargo itself
export KARGO_HOME="$CI_PROJECT_DIR/.kargo-home"

Terminal output

Read by Kargo, not set by it. An explicit --color overrides them.

VariableEffect
NO_COLORSet to anything to disable colour.
CLICOLOR=0Disable colour.
CLICOLOR_FORCE=1Colour even when the output is piped.

In practice

# A hook that stamps the build
cat > build/generated/version.txt <<EOT
${KARGO_PKG_NAME} ${KARGO_PKG_VERSION}
built for ${KARGO_TARGET} (${KARGO_PROFILE})
with Kotlin ${KARGO_KOTLIN_VERSION}
EOT

Next