1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-30 05:59:39 +02:00

Pipeline resilience - be more verbose (#677)

* Pipeline resilience - be more verbose

Be more verbose about when a pipeline gets into 'UNSTABLE' state.

Collect step name centrally to be able to inform end-users at a later point inside a pipeline (e.g. during an approval step).

* address PR feedback
This commit is contained in:
Oliver Nocon 2019-05-03 14:06:49 +02:00 committed by GitHub
parent 9b7b46132f
commit 46a6525c4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,7 +51,7 @@ import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
@GenerateDocumentation
void call(Map parameters = [:], body) {
// load default & individual configuration
def cpe = parameters.stepParameters?.script?.commonPipelineEnvironment ?: commonPipelineEnvironment
def cpe = parameters.stepParameters?.script?.commonPipelineEnvironment ?: null
Map config = ConfigurationHelper.newInstance(this)
.loadStepDefaults()
.mixinGeneralConfig(cpe, GENERAL_CONFIG_KEYS)
@ -81,12 +81,25 @@ void call(Map parameters = [:], body) {
if (config.failOnError || config.stepName in config.mandatorySteps) {
throw ex
}
if (config.stepParameters?.script) {
config.stepParameters?.script.currentBuild.result = 'UNSTABLE'
} else {
currentBuild.result = 'UNSTABLE'
}
echo "[${STEP_NAME}] Error in step ${config.stepName} - Build result set to 'UNSTABLE'"
List unstableSteps = cpe?.getValue('unstableSteps') ?: []
if(!unstableSteps) {
unstableSteps = []
}
// add information about unstable steps to pipeline environment
// this helps to bring this information to users in a consolidated manner inside a pipeline
unstableSteps.add(config.stepName)
cpe?.setValue('unstableSteps', unstableSteps)
} catch (Throwable error) {
if (config.echoDetails)
message += formatErrorMessage(config, error)