使用Groovy for Jenkins取消排队的构建并中止正在执行的构建 [英] Cancel queued builds and aborting executing builds using Groovy for Jenkins

查看:259
本文介绍了使用Groovy for Jenkins取消排队的构建并中止正在执行的构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于使用Groovy系统脚本的Jenkins,是否可以轻松地搜索构建队列和正在执行构建的列表中的某些条件(特别是与某些条件匹配的参数),然后杀死/取消它们?

For Jenkins using a Groovy System Script, is there a way to easily search the build queue and list of executing builds for some criteria (specifically a parameter that matches some condition) and then kill/cancel them?

我似乎找不到任何方法可以做到这一点,但似乎应该有可能.

I cannot seem to find any way to do this, but it seems like it should be possible.

推荐答案

我自己尚未对其进行测试,而是查看

I haven't tested it myself, but looking at the API it should be possible in the following way:

import hudson.model.*

def q = Jenkins.instance.queue

q.items.findAll { it.task.name.startsWith('my') }.each { q.cancel(it.task) }

相关API链接:

  • http://javadoc.jenkins-ci.org/jenkins/model/Jenkins.html
  • http://javadoc.jenkins-ci.org/hudson/model/Queue.html

这篇关于使用Groovy for Jenkins取消排队的构建并中止正在执行的构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆