22import logging
33import urllib3
44
5-
65from collections import namedtuple
76from jira import JIRA
87from jira import JIRAError
98from library .utility import empty_converter
109
11-
1210NewIssue = namedtuple ('NewIssue' , [
1311 'ticket_id' ,
1412 'ticket_assignee_id'
15- ])
13+ ])
14+
15+ risk_priority_mapping = {
16+ "Critical" : "Blocker" ,
17+ "High" : "Critical" ,
18+ "Medium" : "Major" ,
19+ "Low" : "Minor" ,
20+ "Info" : "Trivial"
21+ }
1622
1723
1824class JiraReporting (object ):
@@ -23,7 +29,7 @@ def __init__(self, config):
2329
2430 def add_issue (self ,
2531 issue_summary , issue_description ,
26- priority , labels ,
32+ risk , labels ,
2733 account_id ,
2834 owner = None ,
2935 bu = None , product = None ,
@@ -42,9 +48,18 @@ def add_issue(self,
4248 "summary" : issue_summary ,
4349 "description" : issue_description ,
4450 "issuetype" : {"name" : self .config .jira .issue_type },
45- "priority" : {"name" : priority },
4651 "labels" : labels
4752 }
53+
54+ if self .config .jira .risk_field_id :
55+ issue_data [self .config .jira .risk_field_id ] = {
56+ self .config .jira .risk_field_param : risk
57+ }
58+ else :
59+ issue_data ["priority" ] = {
60+ {"name" : risk_priority_mapping [risk ]}
61+ }
62+
4863 ticket_id = self .jira .create_ticket (issue_data )
4964
5065 parent_ticket_id = self .config .owners .ticket_parent (
@@ -114,6 +129,7 @@ def ticket_url(self, ticket_id):
114129 def add_label (self , ticket_id , label ):
115130 self .jira .add_label (ticket_id , label )
116131
132+
117133class JiraOperations (object ):
118134 """ Base class for interaction with JIRA """
119135 def __init__ (self , config ):
@@ -330,8 +346,8 @@ def add_comment(self, ticket_id, comment):
330346 def add_watcher (self , ticket_id , user ):
331347 """
332348 Adding jira ticket watcher.
333-
334- :param ticket_id: jira ticket id
349+
350+ :param ticket_id: jira ticket id
335351 :param user: watcher user id
336352 :return: nothing
337353 """
0 commit comments