Jenkins 为什么Groovy抛出错误MissingMethodException:没有方法签名?

Jenkins 为什么Groovy抛出错误MissingMethodException:没有方法签名?,jenkins,groovy,Jenkins,Groovy,我不知道groovy,但我需要修改Jenkins管道中的行为。 我试图从函数中调用函数,但遇到MissingMethodException错误。 我用groovysh(屏幕截图)编写了一个简化的示例。 我不明白什么 class Rocket implements Serializable { static List<String> channelsForAllEvents = [] } Rocket.channelsForAllEvents = ["1"

我不知道groovy,但我需要修改Jenkins管道中的行为。 我试图从函数中调用函数,但遇到MissingMethodException错误。 我用groovysh(屏幕截图)编写了一个简化的示例。 我不明白什么

class Rocket implements Serializable {
    static List<String> channelsForAllEvents = []
}

Rocket.channelsForAllEvents = ["1", "2", "false"]
println(Rocket.channelsForAllEvents instanceof java.util.List)

def mycall() {
    rocket(Rocket.channelsForAllEvents as java.util.List)
}

def rocket(List<String> channels) {
    println(channels instanceof java.util.List)
    println(channels instanceof java.util.ArrayList)
    println channels
}

mycall()
mypackage.groovy

import groovy.transform.Field
import EnvPool as E

@Field String STEP_NAME = getClass().getName()
@Field Boolean catched = false

def call(Map config, Closure body) {
    println("Stage [${STEP_NAME}] begins")

    // hidden logic
    if (!E.hasChanges) {
        buildSetResult(currentBuild, "SUCCESS")
    } else {
        buildSetResult(currentBuild, "FAILURE")
    }
    notify.call(currentBuild)

    println("Stage [${STEP_NAME}] end")
}
groovy

import EnvPool as E

def call(currentBuild) {
    if (currentBuild.result == "FAILURE") {
        notify.rocket(E.Rocket.channelsForAllEvents + E.Rocket.channelsForOnlyErrors)
    } else {
        notify.rocket(E.Rocket.channelsForAllEvents)
    }
}

def rocket(List<String> channels) {
    channels.each { channel ->
        rocketSend(...) // hidden impl
    }
}

使用
groovyconsole
groovy
而不是
groovysh
,您的脚本就会工作。@daggett,我更新了问题,Jenkins中的代码逻辑似乎是一样的,但我得到了一个错误。将
notify.rocket(
替换为
this.rocket(
import EnvPool as E

def call(currentBuild) {
    if (currentBuild.result == "FAILURE") {
        notify.rocket(E.Rocket.channelsForAllEvents + E.Rocket.channelsForOnlyErrors)
    } else {
        notify.rocket(E.Rocket.channelsForAllEvents)
    }
}

def rocket(List<String> channels) {
    channels.each { channel ->
        rocketSend(...) // hidden impl
    }
}
E.Rocket.channelsForOnlyErrors = []
E.Rocket.channelsForAllEvents = ["build-centos7"]