exception handling take 4

This commit is contained in:
Dominik Chilla 2020-07-11 23:58:20 +02:00
parent 9941894a4f
commit 74d6924cf6

26
Jenkinsfile vendored
View File

@ -8,19 +8,21 @@ pipeline {
steps {
script {
def userInput
try {
timeout(time: 5, unit: 'SECONDS') {
userInput = input(id: 'Proceed1', message: 'Was this successful?', parameters: [[
$class: 'BooleanParameterDefinition',
defaultValue: true,
description: '',
name: 'Please confirm you agree with this'
]])
catchError(buildResult: 'SUCCESS', stageResult: 'ABORTED') {
try {
timeout(time: 15, unit: 'SECONDS') {
userInput = input(id: 'Proceed1', message: 'Was this successful?', parameters: [[
$class: 'BooleanParameterDefinition',
defaultValue: true,
description: '',
name: 'Please confirm you agree with this'
]])
}
} catch(org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) {
error "Caught ${e.toString()}"
} catch(err) { // input false
echo "This job has been aborted"
}
} catch(org.jenkinsci.plugins.workflow.steps.FlowInterruptedExceptionedException e) {
echo "This job timed out"
} catch(err) { // input false
echo "This job has been aborted"
}
if (userInput == true) {
// do something