CodeNOW Context Variables
Every time an application component is deployed to a target environment, CodeNOW automatically
injects a fixed set of CN_-prefixed environment variables into the running container. They
expose the component's CodeNOW context — which account, application, component, version, environment,
cluster and deployment it belongs to — so the running code can introspect where and as what it is
deployed, without calling back to the platform.
These variables are platform-managed: you do not define them in the Deployment Configuration, and they are added on top of your own environment variables and any variables injected from connected services.
CodeNOW context variables are injected into application components only. They are not added to containers or hosted services.
Available variables
The following variables make up the current (v1) set. Values shown are illustrative examples.
| Variable | Meaning | Example |
|---|---|---|
CN_ACCOUNT_ID | Identifier of the account the component belongs to | acc-1 |
CN_ACCOUNT_NAME | Account name — currently equal to the account id (see note below) | acc-1 |
CN_APPLICATION_ID | Identifier of the application | app-1 |
CN_APPLICATION_NAME | Human-readable application name | My Application |
CN_COMPONENT_ID | Identifier of the application component | comp-1 |
CN_COMPONENT_NAME | Human-readable component name | My Component |
CN_COMPONENT_VERSION | Deployed version of the component | 1.2.3 |
CN_PACKAGE_VERSION | Version of the resolved package — not set for agent components (see below) | 2.0.0 |
CN_IMAGE_TAG | Container image tag deployed | 1.2.3 |
CN_ENVIRONMENT_ID | Identifier of the target environment | prod-env |
CN_ENVIRONMENT_NAME | Human-readable environment name | Production |
CN_ENVIRONMENT_TYPE | Environment classification — prod or nonprod only | prod |
CN_CLUSTER_ID | Identifier of the cluster the component runs on | cluster-1 |
CN_CLUSTER_NAME | Human-readable cluster name | EU Cluster |
CN_NAMESPACE | Kubernetes namespace — equal to the environment id | prod-env |
CN_DEPLOYMENT_ID | Identifier of this deployment | dep-uuid |
As-built behavior
A few values behave differently from what their name might suggest:
CN_ENVIRONMENT_TYPEisprodornonprodonly. It is derived from whether the target environment is the application's designated production environment. There is nostage/dev/testdistinction in this version.CN_PACKAGE_VERSIONis present for every ordinary component. Every deployment resolves a build/package, so it is emitted — except for agent components (see below).CN_ACCOUNT_NAMEcurrently equals the account id. No separate account display name exists yet, so the id is used as a fallback.CN_NAMESPACEequals the environment id.
Agent components
Agent components (deployed as part of an agent swarm) receive the same set of variables except
CN_PACKAGE_VERSION.
This value can change on a redeploy even when nothing about the agent itself changed. Injecting it
would alter the pod specification and cause the agent pods to roll (restart) on a mere redeploy. Leaving
it out keeps agent pods running until something that actually affects them changes.
CN_DEPLOYMENT_ID and all other CN_ variables are injected into agent components as usual.
Overriding and naming collisions
The CN_ block is applied after your own environment variables. As a result:
If you define your own environment variable using the CN_ prefix, the platform-injected value takes
precedence and overwrites yours. In this version the CN_ prefix is not reserved or blocked — but
to avoid surprises, do not use the CN_ prefix for your own variables. Reserving and enforcing the
prefix is planned for a future iteration.
Not included in this version
The following are intentionally out of scope for the current version and are not emitted:
CN_DEPLOYED_BY— no manual-vs-automated deployment actor signal exists yet.CN_IMAGE_DIGEST— only the image tag is available at deploy time.
Provenance metadata, platform URLs, pod-level details and OpenTelemetry-oriented variables are tracked as future work.