Jenkins Job DSL-没有方法的签名:Java.lang.string.call()



我无法运行此代码:

buildPath = 'applications'
buildJob(['java', 'nodejs'])

def buildJob(def jobList){
  for(job in jobList){
    def jobName = "${job}_seed"
    def jobDescription = "Jenkins DSL seed for ${job}"
    def jobScriptPath = "resources/dsl/${jobName}.groovy"
    job("${buildPath}/${jobName}")
  }
}

所以,我遇到了这个错误:

Processing provided DSL script
ERROR: (script, line 12) No signature of method: java.lang.String.call() is applicable for argument types: (org.codehaus.groovy.runtime.GStringImpl) values: [applications/java_seed]
Possible solutions: wait(), any(), wait(long), take(int), each(groovy.lang.Closure), any(groovy.lang.Closure)
Finished: FAILURE

我看不到导致此错误的地方或什么。我在buildJob(def jobList)函数之外创建了一个作业,它正在工作,但是我需要进行循环以自动化作业创建。

有什么想法?

发布我遇到的类似问题。在这个问题上,网络上并不多。

No signature of method: java.lang.String.call() is applicable for argument types: (java.lang.String) values: [some-value]

说我们正在实现一个作业DSL插件(https://github.com/jenkinsci/multibranch-build-strategy-extension-plugin(例:

includeRegionBranchBuildStrategy {
    includedRegions(String value)
}

我们有:

的代码
def includedRegions = r ? String.join("n", r) : null
branchSources {
  branchSource {
    buildStrategies {
      if(includedRegions){
        includeRegionBranchBuildStrategy {
          includedRegions(includedRegions)
        }
      }
    }
  }
}

需要重命名您的变量才能使其工作!例如,该方法不能与上面定义的VAR具有相同的名称。

def regions = r ? String.join("n", r) : null
branchSources {
  branchSource {
    buildStrategies {
      if(regions){
        includeRegionBranchBuildStrategy {
          includedRegions(regions)
        }
      }
    }
  }
}

您在以下行中迭代字符串数组:

for(job in jobList){

并为此使用变量job

然后,您尝试在此变量上调用方法call

job("${buildPath}/${jobName}")

相关内容

  • 没有找到相关文章

最新更新