首页 > 解决方案 > 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?

标签: jenkinsjenkins-plugins

解决方案


如果您想将其标记为“失败”会更容易

只需退出 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)
  }

溴,

蒂姆


推荐阅读