diff --git a/common/create_bug.go b/common/create_bug.go index d105c52..2d5c137 100644 --- a/common/create_bug.go +++ b/common/create_bug.go @@ -63,7 +63,7 @@ func (b *BugInfo) Create() (string, error) { SetTimeout(10 * time.Second) resp, err := client.R(). SetBodyJsonMarshal(b). - Post(API_tbapi + "/api/tb/v2/bug/create") + Post(API_tbapi + "/api/bug/v2/create") if err != nil { fmt.Println("Teambition提单失败:", err) return "", err @@ -72,8 +72,12 @@ func (b *BugInfo) Create() (string, error) { fmt.Println("Teambition提单失败:", resp.StatusCode, resp.String()) return "", err } + if gjson.Get(resp.String(), "code").Int() != 200 { + return "", errors.New(gjson.Get(resp.String(), "msg").String()) + } bug_id := gjson.Get(resp.String(), "data").String() if len(bug_id) == 0 { + fmt.Println(resp.String()) return "", errors.New("请求成功,但返回bug_id为空") } fmt.Println("Teambition提单成功, id =", bug_id) diff --git a/monkey/anomaly.go b/monkey/anomaly.go index 68ca612..1280f57 100644 --- a/monkey/anomaly.go +++ b/monkey/anomaly.go @@ -138,13 +138,15 @@ func createTbBug(ano models.MonkeyAnomaly) { bug_type = "EXCEPTION" } - content := "" + content := "**异常ID:**" + cast.ToString(ano.ID) + " " content += "**关联Monkey报告:** [点击查看](http://qa.flatincbr.work/#/monkey/result/" + cast.ToString(ano.TaskId) + ")" + "\n\n
\n\n" content += "**上报时间:**" + ano.CreateTime.Format("2006-01-02 15:04:05") + "\n\n
\n\n" content += "**应用版本:**" + task.Version + "\n\n
\n\n" content += "**信息预览:**" + "\n\n" title := "【Monkey测试】" + + ano.JsonReady() for i, v := range ano.Anomalies { for ii, vv := range strings.Split(v, "\n") { content += "> " + vv + "\n" @@ -176,7 +178,7 @@ func createTbBug(ano models.MonkeyAnomaly) { content += "> " + "(...更多请查看Monkey报告)" + "\n" content += "\n" - bug := common.NewBug("crushu") //task.Project + bug := common.NewBug(task.Project) //task.Project bug.SetTitle(title). SetPlatform(task.Platform).