playground-jenkins/Jenkinsfile

48 lines
1.3 KiB
Groovy

@Library('jenkins-shlib')_
pipeline {
agent any
stages {
stage('Approve'){
steps {
script {
def userInput
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"
}
}
if (userInput == true) {
// do something
echo "this was successful"
} else {
// do something else
echo "this was not successful"
currentBuild.result = 'FAILURE'
}
}
}
}
}
post {
always {
script {
env.RESULT = "${currentBuild.currentResult}"
echo "FINAL RESULT: ${env.RESULT}"
}
}
}
}