「Jenkins Pipeline」- hudson.remoting.ProxyException

  CREATED BY JENKINSBOT

问题描述

在执行Jenkins Pipeline构建任务时,产生如下错误:

...
[Pipeline] Start of Pipeline
[Pipeline] End of Pipeline
hudson.remoting.ProxyException: com.cloudbees.groovy.cps.impl.CpsCallableInvocation
Finished: FAILURE

问题原因

该错误是由于在构造函数中调用其他类的方法导致的。不能在构造函数中调用NonCPS方法。如果需要调用NonCPS方法,需要为方法添加@NonCPS注解。

另外在构造函数中也无法获取其他类的成员变量。

解决办法

不在构造函数中使用NonCPS方法。或者为方法添加@NonCPS注解。

参考文献

jenkins shared library error com.cloudbees.groovy.cps.impl.CpsCallableInvocation
Constructor, using other methods of the class, causes “hudson.remoting.ProxyException: com.cloudbees.groovy.cps.impl.CpsCallableInvocation”
[JENKINS-26313] Add javadoc explaining why constructors can’t be transformed #83