我在 IntelliJ IDE 中开发了 groovy 类,我想在 Jenkins 管道插件的“管道脚本”中实例化其中一个类。我尝试遵循 'Eval.me' 和 class.forName 的示例
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()
最佳答案
我认为我两周前提出的帖子可以回答你的问题。 Create resusable jenkins pipeline script
关于java - 动态加载 Groovy 类并调用管道脚本中的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38788441/