How to use Environment Variables in build.sbt?

You can get env variables with the commands mentioned other responses like:

sys.env.get("USERNAME")
sys.env.get("PASSWORD")

but they return an option of type Option[String]

To turn this into string you need to either do a match or simply use

sys.env.get("USERNAME").get
sys.env.get("USERNAME").getOrElse("some default value")

if you need to set some default value. Warning! calling .get of an option that does not have value will give you a runtime error.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)