Sbt用于连续积分:打印stacktrace并在出错时退出 [英] Sbt for continuous integration: print stacktrace and exit on error

查看:663
本文介绍了Sbt用于连续积分:打印stacktrace并在出错时退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Sbt进行连续集成(Bamboo)。我想检查所有环境变量是否设置或获取描述性错误消息。我使用以下方法:

  def env(n:String)= Option(System.getenv(n))。getOrElse抛出新的RuntimeException(未定义所需的环境变量+ n))

val mySetting = env(REQUIRED_ENV_VAR)+...
pre>

而是,我获得

  [error] java.lang .ExceptionInInitializerError 
[错误]对完整日志使用last。
项目加载失败:(r)etry,(q)uit,(l)ast,或(i)gnore? q

两个问题:


  1. 如何获取完整的stacktrace而不需要使用'last'(简单不能在Bamboo上做)?

  2. 如果项目加载失败,如何告诉sbt退出要求重试等?


解决方案

如果输入流将被禁用,sbt将不会启用交互模式closewith(such a hacky)trick:

  cat / dev / null | sbt taskname 

或者如果您不能使用管道创建一个shell脚本:

 #!/ bin / sh 
sbt$ @< / dev / null


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:

  1. How to get full stacktrace without need to use 'last' (simple can't do it on Bamboo)?
  2. How to tell sbt to exit if project loading failed instead of asking for retry etc?

解决方案

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

这篇关于Sbt用于连续积分:打印stacktrace并在出错时退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆