Feature #36852

Load and use bash/system ENV variables in config YML files

Added by Aleksandar Pavic 6 months ago. Updated 6 months ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:


Target version:-


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

export DB-NAME = "something" 

and in yml file
  database: ${DB-NAME}


#1 Updated by Aleksandar Pavic 6 months ago

I am referring to setup, with rake task.

#2 Updated by Aleksandar Pavic 6 months ago

There are some hacks like this:

But it would be better to be officially supported.

#3 Updated by Thomas Löber 6 months ago

You can use ERB tags in your database.yml, for example:

  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.

Also available in: Atom PDF