jenkins - Raise Abort in Jenkins Job from Batch script
问题描述
I have a Jenkins job, which do Git syncs and build the source code.
I added and created a "Post build task" option.
In 'post build task', I am searching for keyword "TIMEOUT:" in console output (this part is done) and want to declare job as Failed and Aborted if keyword matches.
How can I raise / declare the Job as Aborted from batch script if keyword matches. Something like echo ABORT
?
解决方案
如果您想将其标记为“失败”会更容易
只需退出 1 即可。
从后期构建任务插件中实现“中止”是很棘手的,使用 Groovy 后期构建插件要容易得多。
groovy post build 提供了丰富的功能来帮助你。
比如匹配函数:
def matcher = manager.getLogMatcher(".*Total time: (.*)\$")
if(matcher?.matches()) {
manager.addShortText(matcher.group(1), "grey", "white", "0px", "white")
}
中止功能:
def executor = build.executor ?: build.oneOffExecutor;
if (executor != null){
executor.interrupt(Result.ABORTED)
}
溴,
蒂姆
推荐阅读
- javascript - JQuery trigger('input') 不会触发原生 JavaScript 输入事件
- javascript - 将字符串数组映射到对象键并获取值
- ruby-on-rails - 从控制器发出 POST 请求时,Rails Oauth 请求阶段未能通过 CSRF 验证
- python - 过滤掉/忽略具有快速斜率变化的区域
- javascript - Javascript:合并对象数组,对具有相同键的值求和
- python - 无限循环问题 - 交叉点
- java - 如何在Java泛型中返回将WebDriver传递给它的类的实例
- r - 在 r 中的 for 循环中重复迭代
- wordpress - BuddyPress 应用程序无法与 Memberpress 一起使用
- ruby-on-rails - 为新模型创建随机 UID