2018-10-09 17:09:55 +02:00
|
|
|
import groovy.transform.Field
|
|
|
|
|
|
|
|
@Field STEP_NAME = 'handlePipelineStepErrors'
|
|
|
|
|
2017-11-24 16:59:34 +02:00
|
|
|
|
2018-08-30 16:33:07 +02:00
|
|
|
void call(Map parameters = [:], body) {
|
2017-07-11 15:12:03 +02:00
|
|
|
|
|
|
|
def stepParameters = parameters.stepParameters //mandatory
|
|
|
|
def stepName = parameters.stepName //mandatory
|
|
|
|
def echoDetails = parameters.get('echoDetails', true)
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (stepParameters == null && stepName == null)
|
|
|
|
error "step handlePipelineStepErrors requires following mandatory parameters: stepParameters, stepName"
|
|
|
|
|
|
|
|
if (echoDetails)
|
|
|
|
echo "--- BEGIN LIBRARY STEP: ${stepName}.groovy ---"
|
|
|
|
|
|
|
|
body()
|
|
|
|
|
|
|
|
} catch (Throwable err) {
|
|
|
|
if (echoDetails)
|
|
|
|
echo """----------------------------------------------------------
|
2018-10-17 12:27:24 +02:00
|
|
|
--- ERROR OCCURRED IN LIBRARY STEP: ${stepName}
|
2017-07-11 15:12:03 +02:00
|
|
|
----------------------------------------------------------
|
|
|
|
|
|
|
|
FOLLOWING PARAMETERS WERE AVAILABLE TO THIS STEP:
|
|
|
|
***
|
2018-10-17 12:27:24 +02:00
|
|
|
${stepParameters?.toString()}
|
2017-07-11 15:12:03 +02:00
|
|
|
***
|
|
|
|
|
|
|
|
ERROR WAS:
|
|
|
|
***
|
|
|
|
${err}
|
|
|
|
***
|
|
|
|
|
|
|
|
FURTHER INFORMATION:
|
2017-12-01 16:11:59 +02:00
|
|
|
* Documentation of library step ${stepName}: https://sap.github.io/jenkins-library/steps/${stepName}/
|
|
|
|
* Source code of library step ${stepName}: https://github.com/SAP/jenkins-library/blob/master/vars/${stepName}.groovy
|
|
|
|
* Library documentation: https://sap.github.io/jenkins-library/
|
|
|
|
* Library repository: https://github.com/SAP/jenkins-library
|
2018-08-30 16:33:07 +02:00
|
|
|
|
2017-07-11 15:12:03 +02:00
|
|
|
----------------------------------------------------------"""
|
|
|
|
throw err
|
|
|
|
} finally {
|
|
|
|
if (echoDetails)
|
|
|
|
echo "--- END LIBRARY STEP: ${stepName}.groovy ---"
|
|
|
|
}
|
|
|
|
}
|