1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00
sap-jenkins-library/vars/handlePipelineStepErrors.groovy
Oliver Feldmann 8e70c72ea9 Documentation improvements
Slight improvements on various md files.
Deletion of method-based commonPipelineEnvironment documentation as it
is not used.
2017-12-06 13:24:01 +01:00

46 lines
1.2 KiB
Groovy

def call(Map parameters = [:], body) {
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 """----------------------------------------------------------
--- ERROR OCCURED IN LIBRARY STEP: ${stepName}
----------------------------------------------------------
FOLLOWING PARAMETERS WERE AVAILABLE TO THIS STEP:
***
${stepParameters}
***
ERROR WAS:
***
${err}
***
FURTHER INFORMATION:
* Documentation of step ${stepName}: .../${stepName}/
* Pipeline documentation: https://...
* GitHub repository for pipeline steps: https://...
----------------------------------------------------------"""
throw err
} finally {
if (echoDetails)
echo "--- END LIBRARY STEP: ${stepName}.groovy ---"
}
}