[英]How does one cancel a system groovy script
在Jenkins中,我有一个系统groovy脚本构建步骤。 有没有办法取消长时间运行的脚本,或者在系统groovy脚本中有一些代码可以判断它的构建是否已被取消?
取消构建时,Jenkins将中断正在运行脚本的线程。
因此,您可以手动检查线程的中断状态,并在某些点中止脚本,例如
if (Thread.currentThread().interrupted()) {
throw new InterruptedException()
}
或者你可以让Groovy通过在脚本中包含ThreadInterrupt注释来为你做这件事,例如
@groovy.transform.ThreadInterrupt
还要确保没有任何catch块会吞下InterruptedException。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.