无法实例化Jenkins共享库中的对象 [英] Cannot instantiate an object in Jenkins Shared Library
问题描述
当前,我正在项目中创建Jenkins共享库,并遇到尝试实例化对象的问题.
Currently I am working on creating a Jenkins shared library in my project and facing a problem trying to instantiate an object.
我的应用程序的树形结构
-第1天
-./Jenkinsfile
-./src/File1.groovy
-./test/File1Spec.groovy
-./vars/file1.groovy
Tree structure of my application
- day#1
-- ./Jenkinsfile
-- ./src/File1.groovy
-- ./test/File1Spec.groovy
-- ./vars/file1.groovy
从我的Jenkinsfile文件中,我可以调用file1.function,这将创建一个写在文件./src/File1.groovy中的类对象,它可以正常工作,但是在第二天,我又添加了一个类(src/File2 (.groovy),并尝试在vars/file2.groovy中创建对象,但失败并显示以下错误:
From my Jenkinsfile I can call file1.function which inturn will create a class object written in the file ./src/File1.groovy and it works perfectly, But on day#2, I add one more class(src/File2.groovy) and tried to create an object in vars/file2.groovy and it fails with the following error:
"com.cloudbees.groovy.cps.impl.CpsCallableInvocation"
完成:失败"
"com.cloudbees.groovy.cps.impl.CpsCallableInvocation"
"Finished: FAILURE"
-第2天
-./Jenkinsfile
-./src/File1.groovy
-./src/File2.groovy
-./test/File1Spec.groovy
-./test/File2Spec.groovy
-./vars/file1.groovy
-./vars/file2.groovy
- day#2
-- ./Jenkinsfile
-- ./src/File1.groovy
-- ./src/File2.groovy
-- ./test/File1Spec.groovy
-- ./test/File2Spec.groovy
-- ./vars/file1.groovy
-- ./vars/file2.groovy
任何人都可以给我一个解决方案的线索吗?
Can anyone give me a clue how this can be solved?
/天竺葵
推荐答案
CpsCallableInvocation意味着您从NonCPS
方法或构造函数中调用了像echo
这样的CPS方法.检查您的代码.
CpsCallableInvocation means that you called a CPS method like echo
from within a NonCPS
method or a constructor. Check your code for that.
这篇关于无法实例化Jenkins共享库中的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!