在我的scala測試中,我通過sys.props.getOrElse("cassandra.test.host", DEFAULT_CASSANDRA_TEST_HOST)
讀取environemnt變量。如何將環境變量傳遞給Jenkins中的sbt測試構建步驟?
測試通過Jenkins運行。
我已經添加了一個Build using sbt
作爲構建步驟。
通過觀察在如此相似的問題,我想出了這個解決方案 - 即操作字段設置爲:
'; set javaOptions += "-Dcassandra.test.host=XX.XXX.XXX.XXX"; test'
但它不工作。執行Properties.envOrElse
時,不設置變量。
詹金斯控制檯輸出包含:
[...] [util-sessionizer] $ java -jar /usr/local/bin/sbt-launch.jar '; set javaOptions += "-Dcassandra.test.host=XX.XXX.XXX.XXX"; test' [info] Loading project definition from /jenkins/workspace/util-sessionizer/project/project [info] Loading project definition from /jenkins/workspace/util-sessionizer/project [info] Set current project to util-sessionizer (in build file:/jenkins/workspace/util-sessionizer/) [info] Defining *:javaOptions [info] The new value will be used by *:runner, compile:run::runner and 4 others. [info] Run `last` for details. [info] Reapplying settings... [...]
你在使用什麼測試框架? –
我正在使用scalatest – piercarlo