mirror of
https://github.com/SAP/jenkins-library.git
synced 2026-06-19 22:58:55 +02:00
chore(event): add error details to events (#5732)
Co-authored-by: Valentin <16714035+valfz@users.noreply.github.com>
This commit is contained in:
co-authored by
Valentin
parent
d5e3483905
commit
60e5ff148b
+11
-1
@@ -51,11 +51,21 @@ func PublishTaskRunFinishedEvent(tokenProvider gcp.OIDCTokenProvider, generalCon
|
||||
outcome = "success"
|
||||
}
|
||||
|
||||
eventData, err := newEvent(eventTypeTaskRunFinished, eventSource, map[string]string{
|
||||
var fatalError = map[string]any{}
|
||||
rawErrorDetail := log.GetFatalErrorDetail()
|
||||
if ctx.ErrorCode != "0" && rawErrorDetail != nil {
|
||||
// retrieve the error information from the logCollector
|
||||
if err := json.Unmarshal(rawErrorDetail, &fatalError); err != nil {
|
||||
log.Entry().WithError(err).Warn("could not unmarshal fatal error struct")
|
||||
}
|
||||
}
|
||||
|
||||
eventData, err := newEvent(eventTypeTaskRunFinished, eventSource, map[string]any{
|
||||
"taskName": ctx.StepName,
|
||||
"stageName": ctx.StageName,
|
||||
"outcome": outcome,
|
||||
"pipelineRunId": ctx.PipelineID,
|
||||
"errorDetail": fatalError,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create event: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user