如何捕捉詹金斯工作中止行动

问题描述 投票:2回答:1
  1. 工作是从詹金斯开始的
  2. 服务器创建TCPIP通信并与其他服务器通信
  3. 创建动态作业ID
  4. 手动作业中止,只是关闭tcpip通信,而不是我想使用动态生成的作业ID终止进程,然后关闭tcpip通信。

我想抓住jenkins的工作中止事件,这可能吗?

jenkins jenkins-plugins jenkins-pipeline
1个回答
2
投票

您应该使用currentBuild.currentResult变量来捕获中止状态。

if (currentBuild.currentResult == 'ABORTED') {
    // Do your stuff here
}

只需将其放在脚本的末尾,或者放在finallytry/catch/finally块中。

© www.soinside.com 2019 - 2024. All rights reserved.