小编김현준*_*김현준的帖子

Jenkins Pipeline 抛出 ProxyException“预期调用 Device.<init> 但最终捕获 Device.getIP”

我在 Jenkins 管道中创建了一个这样的类。

class Device
{
    def ip = null
    def context
    
    def getIP(devName) 
    {
        return "aaa.bbb.ccc.ddd"
    }

    Device(context, devName, devType)
    {
        print("[DEBUG] ctor device")
        ip = getIP(devName)
        this.context = context
        print(ip)
    }
}


ap = new Device(this, "DEV", "TYPE")
print ap.ip
Run Code Online (Sandbox Code Playgroud)

当我在“Groovy Web 控制台”( https://groovyconsole.appspot.com/ ) 中尝试它时效果很好,但是当我在 Jenkins 中运行此脚本时,会出现以下错误。

[Pipeline] Start of Pipeline

expected to call Device.<init> but wound up catching Device.getIP; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/

[Pipeline] End of Pipeline

hudson.remoting.ProxyException: CpsCallableInvocation{methodName=getIP, call=com.cloudbees.groovy.cps.impl.CpsFunction@20fd33e6, receiver=Device@57905ade, arguments=[DEV]}

Finished: FAILURE
Run Code Online (Sandbox Code Playgroud)

剧本有什么问题吗?

groovy jenkins jenkins-groovy

4
推荐指数
1
解决办法
9735
查看次数

标签 统计

groovy ×1

jenkins ×1

jenkins-groovy ×1