超时后中止Jenkins管道(工作流)构建

时间:2016-07-12 12:55:40

标签: jenkins jenkins-pipeline

每当构建卡在某处失败时,超时就会启动,但构建不会中止,并且在您取消构建之前它会一直运行,进入控制台并按链接Click here to forcibly terminate running steps

以下是我正在尝试但无法正常工作的示例代码:

stage concurrency: 1, name: 'Build'
def buildSteps = [:]
    buildSteps['Server'] = {
        timeout(1) {
            node('build') {
                timestamps {
                     bat "waitfor nothing /t 120 >nul"
            }
        }
    }   
}

parallel buildSteps

这是日志

[Pipeline] stage (Build)
Entering stage Build
Proceeding
[Pipeline] parallel
[Pipeline] [Server] { (Branch: Server)
[Pipeline] [Server] timeout
[Pipeline] [Server] {
[Pipeline] [Server] node
[Server] Running on CI106 in C:\Jws\workspace\jftimeout
[Pipeline] [Server] {
[Pipeline] [Server] timestamps
[Pipeline] [Server] {
[Pipeline] [Server] bat
14:42:52 [Server] [jftimeout] Running batch script
14:42:53 [Server] 
14:42:53 [Server] C:\Jws\workspace\jftimeout>waitfor nothing /t 120  1>nul 
14:43:52 [Server] Sending interrupt signal to process
Aborted by user
14:49:29 [Server] Sending interrupt signal to process
Click here to forcibly terminate running steps
Terminating bat
[Pipeline] }
[Pipeline] // timestamps
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // timeout
[Pipeline] }
Failed in branch Server
[Pipeline] // parallel
[Pipeline] End of Pipeline

在14:43:52,超时发出停止信号但没有任何反应。

Aborted by user是我手动取消构建

的时候

1 个答案:

答案 0 :(得分:1)

安装构建超时插件https://wiki.jenkins-ci.org/display/JENKINS/Build-timeout+Plugin 转到Manage Jenkins>配置系统>构建超时插件> BuildStep Action> 选中启用BuildStep操作

启用插件后,在达到超时时停止构建。