小编Har*_*lon的帖子

带有超时的输入步骤,继续使用 Jenkins 管道的默认设置

所需 Jenkins 管道的描述:

  • 等待 1 分钟输入(“这是发布版本吗?是/否”)
    • 如果输入为是,则执行发布类型构建(带有构建号和部署)
    • 如果超时或用户说不,则进行测试构建
    • 如果用户按下 Abort 执行正常中止

我目前的代码是:

try {
    timeout(1) {
        input message: 'Do you want to release this build?',
              parameters: [[$class: 'BooleanParameterDefinition',
                            defaultValue: false,
                            description: 'Ticking this box will do a release',
                            name: 'Release']]
    }
} catch (err) {
    def hi = err.getCauses()
    echo "Exception thrown:\n ${hi}"

    echo err.getLocalizedMessage()
    echo err.getCause()
    echo err.toString()
    echo err.getClass().getName()
}
Run Code Online (Sandbox Code Playgroud)

但这给出了相同的(据我所知)行为并捕获了用户按下“中止”和输入超时的错误。

这是超时的输出:

[Pipeline] timeout
[Pipeline] {
[Pipeline] input
Input requested
[Pipeline] }
[Pipeline] // timeout
[Pipeline] echo
Exception …
Run Code Online (Sandbox Code Playgroud)

jenkins jenkins-pipeline

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

jenkins ×1

jenkins-pipeline ×1