Feature #36852
openLoad and use bash/system ENV variables in config YML files
0%
Description
In some scenarios, where Redmine is automatically deployed,
it would be of good use to read EXPORT or ENV variables and use them in config .yml files like database.yml
For example like elsastic
https://www.elastic.co/guide/en/beats/winlogbeat/current/using-environ-vars.html
export DB-NAME = "something"
and in yml file
production: database: ${DB-NAME}
Updated by Aleksandar Pavic over 2 years ago
I am referring to setup, with rake task.
Updated by Aleksandar Pavic over 2 years ago
There are some hacks like this:
https://stackoverflow.com/questions/15045369/redmine-email-configuration-with-environment-variables
But it would be better to be officially supported.
Updated by Thomas Löber over 2 years ago
You can use ERB tags in your database.yml
, for example:
production: database: "<%= ENV["PRODUCTION_DATABASE"] %>"
From https://edgeguides.rubyonrails.org/configuring.html#configuring-a-database
The config/database.yml file can contain ERB tags <%= %>. Anything in the tags will be evaluated as Ruby code. You can use this to pull out data from an environment variable or to perform calculations to generate the needed connection information.