diff --git a/cloudevents-server/pkg/events/custom/tekton/lark.go b/cloudevents-server/pkg/events/custom/tekton/lark.go index abe6a22..ead9e0e 100644 --- a/cloudevents-server/pkg/events/custom/tekton/lark.go +++ b/cloudevents-server/pkg/events/custom/tekton/lark.go @@ -153,9 +153,9 @@ func extractLarkInfosFromEvent(event cloudevents.Event, baseURL string) (*cardMe if results := data.PipelineRun.Status.PipelineResults; len(results) > 0 { var parts []string for _, r := range results { - parts = append(parts, fmt.Sprintf("**%s**:", r.Name), r.Value, "---") + parts = append(parts, fmt.Sprintf("%s:", r.Name), r.Value) + ret.Results = append(ret.Results, [2]string{r.Name, r.Value}) } - ret.Results = strings.Join(parts, "\n") } case data.TaskRun != nil: startTime = data.TaskRun.Status.StartTime @@ -170,8 +170,8 @@ func extractLarkInfosFromEvent(event cloudevents.Event, baseURL string) (*cardMe for _, r := range results { v, _ := r.Value.MarshalJSON() parts = append(parts, fmt.Sprintf("**%s**:", r.Name), string(v), "---") + ret.Results = append(ret.Results, [2]string{r.Name, string(v)}) } - ret.Results = strings.Join(parts, "\n") } case data.Run != nil: startTime = data.Run.Status.StartTime @@ -181,8 +181,9 @@ func extractLarkInfosFromEvent(event cloudevents.Event, baseURL string) (*cardMe 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}) + } - ret.Results = strings.Join(parts, "\n") } } diff --git a/cloudevents-server/pkg/events/custom/tekton/lark_templates/tekton-run-notify.yaml.tmpl b/cloudevents-server/pkg/events/custom/tekton/lark_templates/tekton-run-notify.yaml.tmpl index fe827ec..65c4c63 100644 --- a/cloudevents-server/pkg/events/custom/tekton/lark_templates/tekton-run-notify.yaml.tmpl +++ b/cloudevents-server/pkg/events/custom/tekton/lark_templates/tekton-run-notify.yaml.tmpl @@ -26,8 +26,12 @@ elements: - tag: markdown content: |- **Results:** - -{{ indent 6 . }} + {{- range . }} + - **{{ index . 0 }}:** + ```YAML +{{ indent 6 (index . 1) }} + ``` + {{- end }} {{- end }} {{- with .RerunURL }} - tag: hr @@ -35,7 +39,9 @@ elements: content: |- 🔧 **Rerun:** - {{ . }}" + ```BASH + {{ . }} + ``` {{- end }} - tag: action actions: diff --git a/cloudevents-server/pkg/events/custom/tekton/types.go b/cloudevents-server/pkg/events/custom/tekton/types.go index 634bcc4..b07290b 100644 --- a/cloudevents-server/pkg/events/custom/tekton/types.go +++ b/cloudevents-server/pkg/events/custom/tekton/types.go @@ -13,7 +13,7 @@ type cardMessageInfos struct { StartTime string EndTime string TimeCost string - Results string + Results [][2]string // Key-Value pairs. } var larkCardHeaderTemplates = map[tektoncloudevent.TektonEventType]string{