playground-jenkins/Jenkinsfile
2020-07-11 23:21:21 +02:00

44 lines
1.0 KiB
Groovy

@Library('jenkins-shlib')_
pipeline {
agent any
stages {
stage('Approve'){
steps {
script {
def userInput
try {
userInput = input(id: 'Proceed1', message: 'Was this successful?', parameters: [[
$class: 'BooleanParameterDefinition',
defaultValue: true,
description: '',
name: 'Please confirm you agree with this'
]])
} catch(err) { // input false
def user = err.getCauses()[0].getUser()
userInput = false
echo "Aborted by: [${user}]"
}
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}"
}
}
}
}