playground-jenkins/Jenkinsfile

47 lines
1.2 KiB
Groovy

@Library('jenkins-shlib')_
pipeline {
agent any
stages {
stage('Approve'){
steps {
script {
import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
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'
]])
}
} catch(FlowInterruptedException e) {
echo "This job timed out"
} 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}"
}
}
}
}