diff --git a/pkg/component/application/jira/v0/issues.go b/pkg/component/application/jira/v0/issues.go index 95900ae64..a00be48dd 100644 --- a/pkg/component/application/jira/v0/issues.go +++ b/pkg/component/application/jira/v0/issues.go @@ -26,6 +26,8 @@ type Issue struct { Self string `json:"self"` IssueType string `json:"issue-type"` Status string `json:"status"` + Labels []string `json:"labels"` + Assignee string `json:"assignee"` } type GetIssueInput struct { @@ -49,6 +51,22 @@ func extractIssue(issue *Issue) *Issue { issue.Summary = summary } } + if len(issue.Labels) == 0 && issue.Fields["labels"] != nil { + if labels, ok := issue.Fields["labels"].([]interface{}); ok { + for _, label := range labels { + if strLabel, ok := label.(string); ok { + issue.Labels = append(issue.Labels, strLabel) + } + } + } + } + if issue.Assignee == "" && issue.Fields["assignee"] != nil { + if assignee, ok := issue.Fields["assignee"].(map[string]interface{}); ok { + if name, ok := assignee["name"].(string); ok { + issue.Assignee = name + } + } + } if issue.IssueType == "" && issue.Fields["issuetype"] != nil { if issueType, ok := issue.Fields["issuetype"]; ok { if issue.IssueType, ok = issueType.(map[string]interface{})["name"].(string); !ok { @@ -305,6 +323,8 @@ type CreateIssueInput struct { IssueType IssueType `json:"issue-type"` Summary string `json:"summary"` Description string `json:"description"` + Labels []string `json:"labels"` + Assignee string `json:"assignee"` } type CreateIssueRequset struct { Fields map[string]interface{} `json:"fields"` @@ -340,6 +360,14 @@ func convertCreateIssueRequest(issue *CreateIssueInput) *CreateIssueRequset { "description": issue.Description, }, } + if len(issue.Labels) > 0 { + newRequest.Fields["labels"] = issue.Labels + } + if issue.Assignee != "" { + newRequest.Fields["assignee"] = map[string]string{ + "name": issue.Assignee, + } + } if issue.IssueType.ParentKey != "" { newRequest.Fields["parent"] = map[string]interface{}{ "key": issue.IssueType.ParentKey,