jbake icon indicating copy to clipboard operation
jbake copied to clipboard

Override Config/Environment-based Config Files

Open wbrawner opened this issue 6 years ago • 3 comments

I saw #490 but I'm looking for more of a global override. The use case is as follows:

  1. I set up my site with CI to deploy to production for the master branch and staging for anything else
  2. In production, the site is the root content, but in staging, the site is in a subdirectory (i.e. example.com/ for production and dev.example.com/static/ for staging)
  3. For each environment, I'd like to at least modify the site.host config value, but there might be other config values that could be useful to change per-environment that I haven't thought of.

Possible implementations:

  1. Enable individual config overrides through a command line flag
jbake generate --config "site.host=https://example.com"
  1. Enable declaring an alternate config file
jbake generate --config-file production.properties

I think the second would probably be the easier of the two to implement, though the first would allow for less copy/paste for shared config between multiple environments.

If this is something you'd be interested in implementing, I'd be happy to contribute the code myself (I just wanted to get the conversation started before I went ahead and did anything)

wbrawner avatar Jan 10 '19 02:01 wbrawner

I like that. Would be a nice addition. How do you help yourself at present? Are you using sed for an inline replacement of values or do you copy property file templates per environment?

ancho avatar Jan 10 '19 07:01 ancho

At the moment I don't deploy from CI, I just build and archive the artifacts and manually push after manually modifying the config, but I was going to set up something with sed before I realized I'm probably not the only one who would benefit from this.

wbrawner avatar Jan 10 '19 12:01 wbrawner

This may already be possible through the SystemConfiguration option by defining a system property on the command line, although the order of loading probably needs to be altered so anything defined on the command line overrides any values in the config files.

jonbullock avatar Jan 22 '19 23:01 jonbullock