Sbt for continuous integration: print stacktrace and exit on error

continuous-integration, sbt, scala

Solution

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

Problem

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: - How to get full stacktrace without need to use 'last' (simple can't do it on Bamboo)? - How to tell sbt to exit if project loading failed instead of asking for retry etc?

Original source