Setup Environment ID as Environment Variable

In scripts, like workflows, task stage hooks or modification methods, it can be useful to know in which environment the script is running. So the script can be used in several environments and behave depending on them.

This can be achieved by setting an environment variable. This has to be set in XDM´s core-server and dataflow-server to use it in any script.

Docker installation

For a Docker installation the environment variable has to be added to the docker-compose.yml file. Add the new environment variable to the environment section of the core-server and dataflow-server.

core-server:
        environment:
            - xdm.core.environment-id=Prod

dataflow-server:
        environment:
            - xdm.core.environment-id=Prod
Kubernetes installation

For a Kubernetes installation the environment variable has to be added to the values.yml file. Add the new environment variable to the environment section of the core and dataflow.

core:
  environment:
    - name: "xdm.core.environment-id"
    - value: <environment-id>

deployer:
  configuration:
    environmentVariables:
      xdm.core.environment-id: <environment-id>
Use the environment variable in scripts

To use the environment variable in a script it can be read this way.

  • Groovy

  • Java-Script

def environment = System.getenv("xdm.core.environment-id")
var environment = System.getenv("xdm.core.environment-id");