From 80b3cc0627482adc17ce2822ae9368dd9d22267d Mon Sep 17 00:00:00 2001 From: Ice3man Date: Mon, 19 Aug 2024 06:20:12 +0530 Subject: [PATCH] feat: jira accept issue-type and project ids (#5537) * feat: jira accept issue-type and project ids * remove validation for project name --------- Co-authored-by: sandeep <8293321+ehsandeep@users.noreply.github.com> --- pkg/reporting/trackers/jira/jira.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/reporting/trackers/jira/jira.go b/pkg/reporting/trackers/jira/jira.go index 5499445c87..6cb976c44e 100644 --- a/pkg/reporting/trackers/jira/jira.go +++ b/pkg/reporting/trackers/jira/jira.go @@ -70,9 +70,13 @@ type Options struct { // Token is the token for jira instance. Token string `yaml:"token" json:"token" validate:"required"` // ProjectName is the name of the project. - ProjectName string `yaml:"project-name" json:"project_name" validate:"required"` + ProjectName string `yaml:"project-name" json:"project_name"` + // ProjectID is the ID of the project (optional) + ProjectID string `yaml:"project-id" json:"project_id"` // IssueType (optional) is the name of the created issue type IssueType string `yaml:"issue-type" json:"issue_type"` + // IssueTypeID (optional) is the ID of the created issue type + IssueTypeID string `yaml:"issue-type-id" json:"issue_type_id"` // SeverityAsLabel (optional) sends the severity as the label of the created // issue. SeverityAsLabel bool `yaml:"severity-as-label" json:"severity_as_label"` @@ -183,6 +187,7 @@ func (i *Integration) CreateNewIssue(event *output.ResultEvent) (*filters.Create Project: jira.Project{Key: i.options.ProjectName}, Summary: summary, } + // On-prem version of Jira server does not use AccountID if !i.options.Cloud { fields = &jira.IssueFields{ @@ -195,6 +200,12 @@ func (i *Integration) CreateNewIssue(event *output.ResultEvent) (*filters.Create Unknowns: customFields, } } + if i.options.IssueTypeID != "" { + fields.Type = jira.IssueType{ID: i.options.IssueTypeID} + } + if i.options.ProjectID != "" { + fields.Project = jira.Project{ID: i.options.ProjectID} + } issueData := &jira.Issue{ Fields: fields,