问题描述
我想在Groovy管道中运行多个线程。这是我的管道
node{
List<Thread> cleanupThreads = new ArrayList<>(100);
"""1 2 3 4 5 6""".split().each{
def th = new Thread({
Random rand = new Random()
def wait = (long)(rand.nextDouble() * 1000)
this.sleep wait
println "Running Thread ${this.getName()}"
})
cleanupThreads.add(th)
}
cleanupThreads.each {it.start() }
cleanupThreads.each {it.join() }
}
运行它时,在控制台中看不到任何“运行线程$ {this.getName()}”输出行
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/test_jobs/multithreaded_groovy_pipeline
[Pipeline] {
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
有什么想法吗? Jenkins管道是否支持多线程?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)