我在IntelliJ IDE中开发了groovy类,我想在Jenkins的Pipeline插件的'Pipeline script'中实例化这些类中的一个。我试图按照试过下面还有“Eval.me”和的Class.forName动态加载一个groovy类并调用流水线脚本中的方法
Sample
package com.mycomp.tmo
/**
* Created by
*/
public void callMe(){
println("Hello World !")
}
def e = "callMe"
def cl = Class.forName("com.mycomp.tmo.Sample")
println(Eval.me("${c1} (${e})"))
的例子:
String cls = 'D:\\Users\\b\\IdeaProjects\\Automation\\src\\com\\mycomp\\tmo\\DBConnectionManager'
def map = ['person': ${cls}]
map['person'].newInstance()
管道插件groovy沙盒根本无法识别类。 –