added remark for notify

master
solar 2020-07-03 11:58:22 +08:00 committed by qiang.ou
parent ac2f01f144
commit c59f8b730a
4 changed files with 7 additions and 1 deletions

1
go.mod
View File

@ -27,6 +27,7 @@ require (
github.com/urfave/cli v1.20.0 github.com/urfave/cli v1.20.0
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5 // indirect golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5 // indirect
golang.org/x/net v0.0.0-20190522155817-f3200d17e092 golang.org/x/net v0.0.0-20190522155817-f3200d17e092
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f // indirect
golang.org/x/text v0.3.2 // indirect golang.org/x/text v0.3.2 // indirect
google.golang.org/genproto v0.0.0-20190530194941-fb225487d101 // indirect google.golang.org/genproto v0.0.0-20190530194941-fb225487d101 // indirect
google.golang.org/grpc v1.21.0 google.golang.org/grpc v1.21.0

View File

@ -16,19 +16,22 @@ const slackTemplate = `
: {{.TaskName}} : {{.TaskName}}
: {{.Status}} : {{.Status}}
: {{.Result}} : {{.Result}}
: {{.Remark}}
` `
const emailTemplate = ` const emailTemplate = `
ID: {{.TaskId}} ID: {{.TaskId}}
: {{.TaskName}} : {{.TaskName}}
: {{.Status}} : {{.Status}}
: {{.Result}} : {{.Result}}
: {{.Remark}}
` `
const webhookTemplate = ` const webhookTemplate = `
{ {
"task_id": "{{.TaskId}}", "task_id": "{{.TaskId}}",
"task_name": "{{.TaskName}}", "task_name": "{{.TaskName}}",
"status": "{{.Status}}", "status": "{{.Status}}",
"result": "{{.Result}}" "result": "{{.Result}}",
"remark": "{{.Remark}}"
} }
` `

View File

@ -69,6 +69,7 @@ func parseNotifyTemplate(notifyTemplate string, msg Message) string {
"TaskName": msg["name"], "TaskName": msg["name"],
"Status": msg["status"], "Status": msg["status"],
"Result": msg["output"], "Result": msg["output"],
"Remark": msg["remark"],
}) })
return buf.String() return buf.String()

View File

@ -456,6 +456,7 @@ func SendNotification(taskModel models.Task, taskResult TaskResult) {
"output": taskResult.Result, "output": taskResult.Result,
"status": statusName, "status": statusName,
"task_id": taskModel.Id, "task_id": taskModel.Id,
"remark": taskModel.Remark,
} }
notify.Push(msg) notify.Push(msg)
} }