tree: ac2dcc1a684d5c4d94a875f7323b735aafe48a04 [path history] [tgz]
  1. .bazelignore
  2. .bazelrc
  3. BUILD.bazel
  4. define.spec.js
  5. package.json
  6. README.md
  7. WORKSPACE
  8. yarn.lock
e2e/define_var/README.md

Defining environment variables

This example shows how you can set environment variables when running Bazel, then access them inside your program.

  1. Use the --define=some_env=some_value option to Bazel, as shown here in package.json
  2. Bazel is hermetic, so if you want some_env to be exposed into the environment of an action, it must be declared, using configuration_env_vars = ["some_env"] as shown here in BUILD.bazel.
  3. In your Node.js program, reference process.env['some_env'] as usual, shown here in define.spec.js.