我正在尝试开发共享库并具有以下目录结构
我的Jenkinsfile只调用test.groovy 中可用的方法和所需的输入。它导入 MyTest 并创建对象并调用构造函数,然后是执行MyTest.groovy文件中可用功能的实际方法
这里的构造函数类从未从全局 vars/test.groovy 调用
我尝试从 groovy 调用类和方法它工作正常但是当我从 jenkinsfile 调用它时它不起作用。我不知道为什么我无法调用构造函数以及我缺少什么。
我已将@NonCPS放在上面的 test.groovy 方法上,但仍然无法正常工作。
//MyTest.groovy
package com.mycompany
class MyTest implements Serializable {
public _notification
MyTest(Closure content) {
notification = [:]
content.resolveStrategy = Closure.DELEGATE_FIRST
content.delegate = notification
content()
println("Entered Constructor")
this._notification = notification
}
}
//test.groovy
import com.mycopany.MyTest
def notify(Closure content) {
println("This is line i am getting in the output but nothing after …Run Code Online (Sandbox Code Playgroud) groovy jenkins jenkins-groovy jenkins-pipeline jenkins-shared-libraries