0
我在'PreVerifymanager.groovy'中實現了我的GParsPool.withPool,如下所示。Gpars withPool方法從管道中調用
import groovyx.gpars.GParsPool
public class PreVerifyManager {
static final THREADS = 3;
public void callMe() {
PreVerifyManager pf = new PreVerifyManager()
def apps = ["App1","App2","App3"]
GParsPool.withPool(PreVerifyManager.THREADS) {
apps.eachParallel {
pf.CreateFile(it)
}
}
}
public void CreateFile(String path){
path = "D:\\"+path+".txt";
println(path)
File file = new File(path)
file.write("Some text")
}
}
這在我的IDE中使用PreVerifyManager的主要方法正常工作。但是,當我移除主要方法並調用管道腳本中創建的PreVerifyManager對象上的方法callMe時,它不起作用。
管道腳本如下:
node {
def PreVerifyManagerObj
stage 'TibcoConfig'
echo 'Reading Tibco configuration!'
println "****************INSIDE PIPELINE****************"
def parent = getClass().getClassLoader()
def loader = new GroovyClassLoader(parent)
PreVerifyManagerObj = loader.parseClass(new File("D://Tibco_Automation//src//com//meet//PreVerifyManager.groovy")).newInstance()
PreVerifyManagerObj.callMe()
}
它基本上,我整合GParsPool.withPool實現與管道的腳本。任何輸入讚賞。
可能是各自的代碼塊可能有助於他人。 – Rao