githubEdit

Env Var Overrides

Every Config Setting can be overridden by convention by creating environment variables in the shell where you run box. This is idea for CI builds were you want to easily set ForgeBox API keys, or tweak settings for your build. You set set these as actual environment variables or Java system properties of the CLIarrow-up-right.

The var must start with the text box_config_ and will be followed by the name of the setting.

box_config_colorInDumbTerminal=true

For nested settings inside of a struct or array you can use underscores to represent dots.

box_config_endpoints_forgebox_APIToken=my-token-here

The overrides are applied using the same mechanism that the config set command uses, which means you can also pass JSON directly for complex values.

# JSON which will be parsed
box_config_proxy={ "server" : "localhost", "port": 80 }

On OS's like Windows which allow for any manner of special characters, you can provide any string which would also be valid for the config set command. Ex:

# dot-delimited keys
box_config_endpoints.forgebox.APIToken=my-token-here
# array indexes too
box_config_foo.bar[baz].bum[1]=test

When you provide JSON, the append flag will be set to true when adding the configuration to what's already in CommandBox.

Overridden env vars will not be written to the CommandBox.json file and will be lost when box stops. They will also take precedence and override any explicit settings already set.

Module Setting Overrides

Env vars can also be used to override module settings like so:

box_config_modules_moduleName_settingName=value

If the module name has a hyphen, your OS may require you to set the entire module struct as JSON to work around this

Note, for the actual module to pick up your setting, the modue authors will need to be injecting the entire setting struct into their CFCs, which are passed by reference. If a module injects a single setting at startup, you'll have chicken/egg issues where the override is loaded too late.

Last updated

Was this helpful?