I'm using Sbt for continuous integration (Bamboo). I want to check all the environment variables are set or get a descriptive error message. I use the following approach:
def env(n: String) = Option(System.getenv(n)).getOrElse(throw new RuntimeException("Undefined required environment variable " + n))
val mySetting = env("REQUIRED_ENV_VAR") + "..."
Instead, I get
[error] java.lang.ExceptionInInitializerError
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? q
Two questions:
sbt will not enable interactive mode if input stream will be "closed" with (such a hacky) trick:
cat /dev/null | sbt taskname
or if you are not able to use pipes create a shell script like this:
#!/bin/sh
sbt "$@" < /dev/null
In sbt v1.3.9 (and probably earlier) there is the --batch
switch.
$ sbt --help
Usage: sbt [options]
...
--batch disable interactive mode
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With