cat test.scala
println("Hello, " + args(0) + "!")
我发现加载文件有:load命令但是如何将参数传递给脚本? 我正在使用sbt console
答案 0 :(得分:1)
据我了解,这不是你可以在'field_name'
中做的事情。您可以使用以下命令将文件作为脚本运行:
field.name
如果你想在withCredentials([usernamePassword(credentialsId: 'amazon',
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
// available as an env variable, but will be masked if you try to print it
out any which way
// note: single quotes prevent Groovy interpolation; expansion is by
Bourne Shell, which is what you want
sh 'echo $PASSWORD'
// also available as a Groovy variable
echo USERNAME
// or inside double quotes for string interpolation
echo "username is $USERNAME"
sh "curl -D- -u $USERNAME:$PASSWORD -X GET -H 'Content-Type: application/json' http://<ip-of-server-with-rest-api>/path/to/api/endpoint"
}
中加载它,我认为你必须创建一个代码函数并将其包装在一个对象中,否则它将无法编译:
sbt console
然后您可以使用scala test.scala
sbt console
拨打电话