3

I'm running Tomcat through IntelliJ. My app property file has properties that are filled up by an ENV variable (such as credentials)

DB_PASSWORD=${DB_PASSWORD}

I don't store my credentials on git and these credentials are fetch at run time from a vault. So manually hardcoding these credentials in IntelliJ somewhere is a no go.

Is there a way to pass ENV vars to IntelliJ? Or have IntelliJ load a var file prior starting tomcat ? Or have IntelliJ read the ENV vars of the host (OSX shell in this case)?

Marco
  • 561
  • 4
  • 14

2 Answers2

2

Run -> Edit configurations -> Environment variables

enter image description here

m0skit0
  • 25,268
  • 11
  • 79
  • 127
  • The Tomcat 'Run' config doesn't have these options? – Marco Jan 25 '19 at 13:04
  • 2
    I mean it does have a way to pass "Environment variables" but in a static way. I was more interested to an easier setting where IntelliJ reads them from a file (file that could be dynamically generated before hand) – Marco Jan 25 '19 at 13:53
  • `The Tomcat 'Run' config doesn't have these options?` see https://stackoverflow.com/questions/37603835/intellij-tomcat-run-configuration-does-not-set-environment-variables – Andrey Jan 25 '19 at 14:24
  • @Marco That's nowhere to be seen in your original question. Unfortunately I don't know how to pass environment variables from a file to IntelliJ. You can however make as many run configuration with different values as you like. – m0skit0 Jan 25 '19 at 15:07
1

If you're running Bash, export your environment variables in ~/.bash_profile:

export DB_PASSWORD=*password_here* 

Intellij by default runs Bash in non-interactive mode, so it doesn't load ~/.bashrc.

restassured
  • 1,008
  • 2
  • 9
  • 12