diff --git a/cloudevents-server/pkg/events/tekton/handler.go b/cloudevents-server/pkg/events/tekton/handler.go index 4cea328d..b84f9f14 100644 --- a/cloudevents-server/pkg/events/tekton/handler.go +++ b/cloudevents-server/pkg/events/tekton/handler.go @@ -131,11 +131,8 @@ func fillInfosWithCustomRun(data *v1alpha1.Run, ret *cardMessageInfos) { ret.Params = append(ret.Params, [2]string{p.Name, string(v)}) } if results := data.Status.Results; len(results) > 0 { - var parts []string for _, r := range results { - parts = append(parts, fmt.Sprintf("**%s**:", r.Name), r.Value, "---") ret.Results = append(ret.Results, [2]string{r.Name, r.Value}) - } } } @@ -147,7 +144,9 @@ func fillInfosWithTaskRun(data *v1beta1.TaskRun, ret *cardMessageInfos) { v, _ := p.Value.MarshalJSON() ret.Params = append(ret.Params, [2]string{p.Name, string(v)}) } - if data.Status.GetCondition(apis.ConditionSucceeded).IsFalse() { + succeededCondition := data.Status.GetCondition(apis.ConditionSucceeded) + if succeededCondition.IsFalse() { + ret.FailedMessage = succeededCondition.Message ret.RerunURL = fmt.Sprintf("tkn -n %s task start %s --use-taskrun %s", data.Namespace, data.Spec.TaskRef.Name, data.Name) } @@ -166,7 +165,9 @@ func fillInfosWithPipelineRun(data *v1beta1.PipelineRun, ret *cardMessageInfos) v, _ := p.Value.MarshalJSON() ret.Params = append(ret.Params, [2]string{p.Name, string(v)}) } - if data.Status.GetCondition(apis.ConditionSucceeded).IsFalse() { + succeededCondition := data.Status.GetCondition(apis.ConditionSucceeded) + if succeededCondition.IsFalse() { + ret.FailedMessage = succeededCondition.Message ret.RerunURL = fmt.Sprintf("tkn -n %s pipeline start %s --use-pipelinerun %s", data.Namespace, data.Spec.PipelineRef.Name, data.Name) } @@ -175,7 +176,6 @@ func fillInfosWithPipelineRun(data *v1beta1.PipelineRun, ret *cardMessageInfos) ret.Results = append(ret.Results, [2]string{r.Name, r.Value.StringVal}) } } - } func getFailedTasks(data *v1beta1.PipelineRun, logGetter func(podName, containerName string) string) map[string][]stepInfo { diff --git a/cloudevents-server/pkg/events/tekton/lark_templates/tekton-run-notify.yaml.tmpl b/cloudevents-server/pkg/events/tekton/lark_templates/tekton-run-notify.yaml.tmpl index fd4a61be..1662e260 100644 --- a/cloudevents-server/pkg/events/tekton/lark_templates/tekton-run-notify.yaml.tmpl +++ b/cloudevents-server/pkg/events/tekton/lark_templates/tekton-run-notify.yaml.tmpl @@ -1,6 +1,12 @@ config: wide_screen_mode: true elements: + {{- with .FailedMessage }} + - tag: markdown + content: |- + **Failed summary:** {{ . }} + - tag: hr + {{- end }} - tag: div fields: {{- with .StartTime }} diff --git a/cloudevents-server/pkg/events/tekton/types.go b/cloudevents-server/pkg/events/tekton/types.go index b364c87d..8604e5e3 100644 --- a/cloudevents-server/pkg/events/tekton/types.go +++ b/cloudevents-server/pkg/events/tekton/types.go @@ -14,6 +14,7 @@ type cardMessageInfos struct { StartTime string EndTime string TimeCost string + FailedMessage string Params [][2]string // key-value pairs. Results [][2]string // Key-Value pairs. StepStatuses []stepInfo // name-status pairs.