[英]Dynamically load a groovy class and invoke a method in pipeline script
I have developed groovy classes in IntelliJ IDE, I want to instantiate one of these classes in 'Pipeline script' of Pipeline plugin in Jenkins. 我在IntelliJ IDE中开发了groovy类,我想在Jenkins的Pipeline插件的'Pipeline script'中实例化其中一个类。 I tried to follow the examples of 'Eval.me' and class.forName
我试着遵循'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})"))
Tried Below as well: 在下面尝试:
String cls = 'D:\\Users\\b\\IdeaProjects\\Automation\\src\\com\\mycomp\\tmo\\DBConnectionManager'
def map = ['person': ${cls}]
map['person'].newInstance()
I think the post I asked two weeks ago can answer your question. 我想我两周前发的帖子可以回答你的问题。 Create resusable jenkins pipeline script
创建可重复使用的jenkins管道脚本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.