动态加载groovy类并在管道脚本中调用方法

时间:2016-08-05 11:43:58

标签: java intellij-idea jenkins groovy build-pipeline-plugin

我在IntelliJ IDE中开发了groovy类,我想在' Pipeline script'中实例化其中一个类。 Jenkins的Pipeline插件我试着按照' 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()

1 个答案:

答案 0 :(得分:0)

我认为两周前我问过的帖子可以回答你的问题。 Create resusable jenkins pipeline script