Karate DSL environment configuration ignores KARATE_ENV variable in CI pipelines
0 reputation · 15 Mar 2021, 04:14 UTC
Goal: Ensure that Karate DSL selects the correct environment block from karate-config.js consistently across local development and production CI pipelines.
Constraint: Karate reads only the JVM system property karate.env to determine which environment to load; it does not consult the OS environment variable KARATE_ENV. When CI provides only KARATE_ENV, the framework falls back to the default configuration, leading to missing endpoints or credentials and test failures. This behavior is documented and unchanged across recent releases.
Questions: Is there a supported way for Karate to honor the KARATE_ENV environment variable directly? Should users always expose KARATE_ENV as a JVM system property, or is there a recommended approach to bridge OS env vars to system properties within karate-config.js without modifying the launch script?