1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-03-03 15:02:35 +02:00

handlePipelineStepErrors: add error data to influx measurement (#563)

This commit is contained in:
Christopher Fenner 2019-03-14 13:51:00 +01:00 committed by GitHub
parent 466cee5e1d
commit 851e98aef8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,19 +16,30 @@ void call(Map parameters = [:], body) {
echo "--- Begin library step of: ${stepName} ---"
body()
} catch (Throwable err) {
} catch (Throwable error) {
if (verbose)
message += SimpleTemplateEngine.newInstance()
.createTemplate(libraryResource('com.sap.piper/templates/error.log'))
.make([
stepName: stepName,
stepParameters: stepParameters?.toString(),
error: err
error: error
]).toString()
throw err
writeErrorToInfluxData(parameters, error)
throw error
} finally {
if (verbose)
message += "--- End library step of: ${stepName} ---"
echo message
}
}
private void writeErrorToInfluxData(config, error){
def script = config?.stepParameters?.script
if(script && script.commonPipelineEnvironment?.getInfluxCustomDataMapTags().build_error_message == null){
script.commonPipelineEnvironment?.setInfluxCustomDataMapTagsEntry('pipeline_data', 'build_error_step', config.stepName)
script.commonPipelineEnvironment?.setInfluxCustomDataMapTagsEntry('pipeline_data', 'build_error_stage', script.env?.STAGE_NAME)
script.commonPipelineEnvironment?.setInfluxCustomDataMapEntry('pipeline_data', 'build_error_message', error.getMessage())
}
}