mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
feat: notifications: report failed workspace builds (#14571)
This commit is contained in:
3
coderd/database/migrations/000253_email_reports.down.sql
Normal file
3
coderd/database/migrations/000253_email_reports.down.sql
Normal file
@ -0,0 +1,3 @@
|
||||
DELETE FROM notification_templates WHERE id = '34a20db2-e9cc-4a93-b0e4-8569699d7a00';
|
||||
|
||||
DROP TABLE notification_report_generator_logs;
|
30
coderd/database/migrations/000253_email_reports.up.sql
Normal file
30
coderd/database/migrations/000253_email_reports.up.sql
Normal file
@ -0,0 +1,30 @@
|
||||
INSERT INTO notification_templates (id, name, title_template, body_template, "group", actions)
|
||||
VALUES ('34a20db2-e9cc-4a93-b0e4-8569699d7a00', 'Report: Workspace Builds Failed For Template', E'Workspace builds failed for template "{{.Labels.template_display_name}}"',
|
||||
E'Hi {{.UserName}},
|
||||
|
||||
Template **{{.Labels.template_display_name}}** has failed to build {{.Data.failed_builds}}/{{.Data.total_builds}} times over the last {{.Data.report_frequency}}.
|
||||
|
||||
**Report:**
|
||||
{{range $version := .Data.template_versions}}
|
||||
**{{$version.template_version_name}}** failed {{$version.failed_count}} time{{if gt $version.failed_count 1}}s{{end}}:
|
||||
{{range $build := $version.failed_builds}}
|
||||
* [{{$build.workspace_owner_username}} / {{$build.workspace_name}} / #{{$build.build_number}}]({{base_url}}/@{{$build.workspace_owner_username}}/{{$build.workspace_name}}/builds/{{$build.build_number}})
|
||||
{{- end}}
|
||||
{{end}}
|
||||
We recommend reviewing these issues to ensure future builds are successful.',
|
||||
'Template Events', '[
|
||||
{
|
||||
"label": "View workspaces",
|
||||
"url": "{{ base_url }}/workspaces?filter=template%3A{{.Labels.template_name}}"
|
||||
}
|
||||
]'::jsonb);
|
||||
|
||||
CREATE TABLE notification_report_generator_logs
|
||||
(
|
||||
notification_template_id uuid NOT NULL,
|
||||
last_generated_at timestamp with time zone NOT NULL,
|
||||
|
||||
PRIMARY KEY (notification_template_id)
|
||||
);
|
||||
|
||||
COMMENT ON TABLE notification_report_generator_logs IS 'Log of generated reports for users.';
|
@ -268,6 +268,7 @@ func TestMigrateUpWithFixtures(t *testing.T) {
|
||||
"template_version_variables",
|
||||
"dbcrypt_keys", // having zero rows is a valid state for this table
|
||||
"template_version_workspace_tags",
|
||||
"notification_report_generator_logs",
|
||||
}
|
||||
s := &tableStats{s: make(map[string]int)}
|
||||
|
||||
|
Reference in New Issue
Block a user