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

Ili*_*irB 5 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
Run Code Online (Sandbox Code Playgroud)

这是日志

[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
Run Code Online (Sandbox Code Playgroud)

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

Aborted by user是当我手动取消构建

Ili*_*irB 0

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

在我启用插件后,构建会在超时时停止。

  • 这是不正确的。Pipeline 的超时与 Build-timeout 插件无关。https://issues.jenkins-ci.org/browse/JENKINS-34677 (5认同)