Simple question I got input in declarative pipeline in jenkins. When I click abort on prompt I do not want it to mark build as aborted. To prevent answers that stack already have, I am looking for solution in declarative pipeline, without escaping to scripting.
options {
timeout(time: 1, unit: 'HOURS')
}
steps {
input 'Deploy to UAT?'
deploy()
}
post {
aborted {
script {
//Throws exception(not allowed to use rawBuild)
currentBuild.rawBuild.@result = hudson.model.Result.SUCCESS
//Do not change status because it can only be worse
currentBuild.result = 'SUCCESS'
//Do not change status because it can only be worse
currentBuild.currentResult = 'SUCCESS'
}
}
}
I don't think it's possible to not abort pipeline with the simple input field since that the purpose of it.
What You could do is to use checkbox in the input like
def deployToUat
steps {
script {
deployToUat = input(
id: 'Proceed', message: 'Deploy to UAT?', parameters: [
[$class: 'BooleanParameterDefinition', defaultValue: true, description: '', name: 'Proceed with deployment?']
])
}
}
stage('UAT deployment') {
when {
expression { deployToUat == true }
}
steps {
deploy()
}
}