我写这是为了测试我在JENKINS-44085上看到的想法
def generateStage(String job, String targetVersion,
String rootVersion, Integer sleepTime=0) {
return {
stage("Deploying: ${job}") {
sleep sleepTime
println "Job: $job"
}
}
}
def deployProcs(targetVersion, rootVersion) {
script {
int sleepTime = 0
def procs = ["proc-proc", "proc-proc-high"]
def parallelStagesMap = procs.collectEntries {
["${it}" : generateStage(it, targetVersion, rootVersion, sleepTime)]
sleepTime += 5
}
timestamps {
parallel parallelStagesMap
}
}
}
node('linux') {
deployProcs(10, 10)
}
但是我明白了
java.lang.NoSuchMethodError: No such DSL method 'generateStage' found among steps.
我想念什么?
答案 0 :(得分:1)
您正在呼叫deployProcs(10, 10)
,其中两个参数都是Integer
的类型。调用generateStage
时使用相同的整数参数,这些参数的类型分别为String targetVersion
和String rootVersion
。
一种解决方法是调用deployProcs('10', '10')
或更改def generateStage(String job, Integer targetVersion, Integer rootVersion, Integer sleepTime=0)
,或从generateStage
函数参数中删除类型。