编辑:完整脚本现在只有两行。曾经更改过jdk后,这种方法就可以正常工作并停止工作。
+
无法连接字符串(完整脚本)
output = "hello" + "," + "world"
println output
输出
groovy.lang.MissingMethodException:没有方法签名:
Script1.hello()适用于参数类型:(java.lang.String)
值:[,]可能的解决方案:getAt(java.lang.String),sleep(long),
每个(groovy.lang.Closure),在以下位置拆分(groovy.lang.Closure) org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58) 在 org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:81)
尽管concat功能可以正常运行
output = ("hello".concat(",")).concat("world")
println output
答案 0 :(得分:0)
关于shell
和jenkins api的问题。而不是groovy
...
在将脚本主体而不是$(cat ...)
注入shell之后,您将获得以下命令行
-d "script=output = "hello" + "," + "world""
错误的url-encoded
参数
尝试用--data-urlencode
代替-d
curl --data-urlencode "script=$(cat Script.groovy)" ...
在那之后您可能必须使用双引号...
答案 1 :(得分:0)
免责声明::我对Jenkin-Groovy
不太了解。
Script1.hello() is applicable for argument types: (java.lang.String)
上面的行在您的错误跟踪中表示,它在"hello"
中将字符串Script1
作为方法。确切地说,它试图通过传递Script1.hello(String s)
作为参数来执行","
。既然没有,它会引发错误。
我不确定,但是可以尝试一下
output = 'hello' + ',' + 'world'
println output
注意:在Groovy中,单引号(String
)和双引号(GString
)中有difference
或者,这个
hello = 'hello'
world = 'world'
output = "$hello, $world"
println output