[英]Call utility function from a utility function in a Jenkins Pipeline Shared Library
I am following the example under Accessing steps .我正在按照访问步骤下的示例进行操作。 In
src/org/foo/Zot.groovy
I would like to call a utility function defined in eg src/org/foo/Bar.groovy
.在
src/org/foo/Zot.groovy
我想调用一个在src/org/foo/Bar.groovy
定义的实用函数。 How to do that?怎么做?
I tried several things without success, eg:我尝试了几件事但没有成功,例如:
// src/org/foo/Zot.groovy
package org.foo;
def bar = new org.foo.Bar()
def checkOutFrom(repo) {
bar.someFunction()
git url: "git@github.com:jenkinsci/${repo}"
}
In this case Jenkins hangs on loading the global library.在这种情况下,Jenkins 挂起加载全局库。 I also tried to
import
the file.我也尝试
import
文件。
There have been reproduction of a similar, and probably related problem here: https://issues.jenkins-ci.org/browse/JENKINS-31484这里重现了一个类似的,可能相关的问题: https : //issues.jenkins-ci.org/browse/JENKINS-31484
I reproduced a similar situation using the Global CPS Library.我使用 Global CPS Library 重现了类似的情况。 The executor stack trace shows that the thread gets locked in InvokerInvocationException, like in the link provided.
执行程序堆栈跟踪显示线程在 InvokerInvocationException 中被锁定,就像在提供的链接中一样。
I was able to workaround my small reproduce case by adding the @NonCPS annotation to all the called methods down the line.通过将@NonCPS 注释添加到所有被调用的方法中,我能够解决我的小型复制案例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.