[英]Groovy error No signature of method: java.lang.String.call()
Trying to resolve this in the pipeline script, the loop is working but somehow the script is throwing an error at the time of executing shell for each parameter value which is the nodename.尝试在管道脚本中解决此问题,循环正在工作,但不知何故,脚本在为节点名的每个参数值执行 shell 时抛出错误。 The error is
错误是
first database
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: java.lang.String.call() is applicable for argument types: (java.lang.String, org.jenkinsci.plugins.workflow.cps.CpsClosure2) values: [$node, org.jenkinsci.plugins.wor
Possible solutions: wait(), any(), trim(), size(), next(), grep()
The script:剧本:
node {
properties([
parameters([
booleanParam(name: 'first database', defaultValue: false, description: '') ,
booleanParam(name: 'second database', defaultValue: false, description: '') ,
])
])
stage('Stash') {
def list = []
if("${params['first database']}" == "true") {
list.add("first database")
}
if("${params['second database']}" == "true") {
list.add("second database")
}
list.each { node ->
echo "$node"
node('$node') {
sh """
echo -e "Hostname:\t\t"`hostname`'
"""
}
}
}
}
Your loop variable seems to be conflicting with the node(){}
directive.您的循环变量似乎与
node(){}
指令冲突。 Change the variable name from node
to something else.将变量名称从
node
更改为其他名称。 Refer the following.请参阅以下内容。
list.each { nodeName ->
echo "$nodeName"
node(nodeName) {
sh """
echo -e "Hostname:\t\t"`hostname`'
"""
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.