所需 Jenkins 管道的描述:
我目前的代码是:
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)