简体   繁体   English

Groovy 错误没有方法签名:java.lang.String.call()

[英]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.

相关问题 jenkins job dsl - 没有方法签名:java.lang.String.call() - jenkins job dsl - No signature of method: java.lang.String.call() hudson.remoting.ProxyException: groovy.lang.MissingMethodException: 没有方法签名: java.util.LinkedHashMap.call() 是适用的 - hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: java.util.LinkedHashMap.call() is applicable groovy.lang.MissingMethodException:方法的无签名:java.util.ArrayList - groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList JobDSL-方法java.lang.String的无签名 - JobDSL - No signature of method java.lang.String jenkinspipeline groovy.lang.MissingMethodException:没有方法签名 - jenkinspipeline groovy.lang.MissingMethodException: No signature of method 如何修复“hudson.remoting.ProxyException:groovy.lang.MissingMethodException:没有方法签名:testFunc.call()” - How to fix 'hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: testFunc.call() ' Jenkins:Groovy:不允许脚本使用groovy.lang.GroovyObject方法getProperty java.lang.String - Jenkins : Groovy : Scripts not permitted to use method groovy.lang.GroovyObject getProperty java.lang.String groovy.lang.MissingMethodException:方法的无签名:在詹金斯构建流程的groovy中 - groovy.lang.MissingMethodException: No signature of method: in groovy on jenkins buildflow groovy.lang.MissingMethodException:没有方法签名:为什么 Jenkins 共享管道库会出现此错误? - groovy.lang.MissingMethodException: No signature of method: Why is this error coming for Jenkins Shared Pipeline library? Jenkins groovy.lang.MissingMethodException:没有方法签名:catchError() - Jenkins groovy.lang.MissingMethodException: No signature of method: catchError()
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM