User-provided devworkspace environment variables (provided with spec.template.components[].container.env) can't reference $PROJECT_ROOT or $PROJECT_SOURCE (and probably other "built-in" environment variables that DevWorkspace Operator automatically provisions).
The issue lies in the ordering of environment variables when the devworkspace deployment is created: Kubernetes container environment variables can only reference environment variables that are declared earlier in the list of environment variables. Thus, all user-provided environment variables should be appended to the end of the list of environment variables (after the DWO-provisioned environment variables such as $PROJECT_SOURCE) when creating a devworkspace deployment.
How To Reproduce
Create the following devworkspace on a cluster with DWO installed:
Description
User-provided devworkspace environment variables (provided with
spec.template.components[].container.env
) can't reference $PROJECT_ROOT or $PROJECT_SOURCE (and probably other "built-in" environment variables that DevWorkspace Operator automatically provisions).The issue lies in the ordering of environment variables when the devworkspace deployment is created: Kubernetes container environment variables can only reference environment variables that are declared earlier in the list of environment variables. Thus, all user-provided environment variables should be appended to the end of the list of environment variables (after the DWO-provisioned environment variables such as $PROJECT_SOURCE) when creating a devworkspace deployment.
How To Reproduce
echo $ENV_TEST
. The output will be$(PROJECT_SOURCE)/hey-there
Expected behavior
The output of
echo $ENV_TEST
should be/projects/web-nodejs-sample/hey-there
.Additional context
Che issue demonstrating the error in environment variable ordering: https://github.com/eclipse-che/che/issues/23008#issuecomment-2168627363