def format_search_results(jira_results): """ Given a list of JIRA results, output a printable lists of these results in an acceptable form for email notifications. :param jira_results: the list of JIRA tickets to format """ output = "" if not jira_results: return output for result in jira_results: template = '[%(issue_key)s] - %(issue_summary)s - [%(issue_status)s]\n%(jira_url_prefix)s/browse/%(issue_key)s\n' entry = template % {"jira_url_prefix": config.get('jira', 'jira_url_prefix'), "issue_key": result.key, "issue_summary": result.fields.summary, "issue_status": result.fields.status} output = output + '\n' + entry return output
def format_search_results(jira_results): """ Given a list of JIRA results, output a printable lists of these results in an acceptable form for email notifications. :param jira_results: the list of JIRA tickets to format """ output = "" if not jira_results: return output for result in jira_results: template = '[%(issue_key)s] - %(issue_summary)s - [%(issue_status)s]\n%(jira_url_prefix)s/browse/%(issue_key)s\n' entry = template % { "jira_url_prefix": config.get('jira', 'jira_url_prefix'), "issue_key": result.key, "issue_summary": result.fields.summary, "issue_status": result.fields.status } output = output + '\n' + entry return output
#!/usr/bin/env python import sys import re from rt2jira import jira, config, pp, logger, JIRAError, syslog, resolve rt2jira_regex = re.compile('From: rt2jira\n') action_regex = re.compile('Action: (.*)\n') tid_regex = re.compile('Ticket ID: (.*?)(\r|)\n') # Get the set of tickets that have been inactive for a set amount of time. jira_results = jira.search_issues('project = ' + config.get('jira', 'project') + ' AND component = "' + config.get('jira', 'component') + '" AND status in ("Open") AND createdDate <= startOfDay(-' + config.get('jira', 'auto_resolve_after_days') + 'd) ORDER BY created ASC', maxResults=False) try: for jira_issue in jira_results: logger.info('Processing Ticket (' + jira_issue.key + ')') syslog.syslog(syslog.LOG_INFO, 'Processing Ticket (' + jira_issue.key + ')') # Next, obtain all current comments on the JIRA ticket. jira_comments = jira.comments(jira_issue) ticket_acted_upon = False for existing_comment in jira_comments: action_match = action_regex.search(existing_comment.body) tid_match = tid_regex.search(existing_comment.body) ticket_id = None if tid_match and (len(tid_match.groups()) >= 1): ticket_id = tid_match.group(1) if jira_issue.fields.assignee:
} output = output + '\n' + entry return output # Requestor regex format. from_regex = re.compile('From: (.*?\@FireEye\.com)(\r|)\n') # KB Notified regex format. kb_notified_regex = re.compile( 'KB Notified: (.*?\@FireEye\.com)(?:\r|)(?:\n|)') # Get the set of tickets that require an auto reply. jira_results = jira.search_issues( 'project = ' + config.get('jira', 'project') + ' AND component = "' + config.get('jira', 'component') + '" AND labels in ("' + config.get('jira', 'new_issue_label') + '", "' + config.get('jira', 'new_comment_label') + '") ORDER BY created ASC', maxResults=False) try: for jira_issue in jira_results: logger.info('Processing JIRA Ticket (' + jira_issue.key + ')') syslog.syslog(syslog.LOG_INFO, 'Processing JIRA Ticket (' + jira_issue.key + ')') # Get the original RT ticket ID. ticket_id = None fields_dict = config_get_dict(config, 'jira', 'create_fields') if fields_dict != {}:
for result in jira_results: template = '[%(issue_key)s] - %(issue_summary)s - [%(issue_status)s]\n%(jira_url_prefix)s/browse/%(issue_key)s\n' entry = template % {"jira_url_prefix": config.get('jira', 'jira_url_prefix'), "issue_key": result.key, "issue_summary": result.fields.summary, "issue_status": result.fields.status} output = output + '\n' + entry return output # Requestor regex format. from_regex = re.compile('From: (.*?\@FireEye\.com)(\r|)\n') # KB Notified regex format. kb_notified_regex = re.compile('KB Notified: (.*?\@FireEye\.com)(?:\r|)(?:\n|)') # Get the set of tickets that require an auto reply. jira_results = jira.search_issues('project = ' + config.get('jira', 'project') + ' AND component = "' + config.get('jira', 'component') + '" AND labels in ("' + config.get('jira', 'new_issue_label') + '", "' + config.get('jira', 'new_comment_label') + '") ORDER BY created ASC', maxResults=False) try: for jira_issue in jira_results: logger.info('Processing JIRA Ticket (' + jira_issue.key + ')') syslog.syslog(syslog.LOG_INFO, 'Processing JIRA Ticket (' + jira_issue.key + ')') # Get the original RT ticket ID. ticket_id = None fields_dict = config_get_dict(config, 'jira', 'create_fields') if fields_dict != {}: for k,v in fields_dict.iteritems(): try: if 'ticket_id' in v: ticket_id = eval('jira_issue.fields.' + k) except:
#!/usr/bin/env python import sys import re from rt2jira import jira, config, pp, logger, JIRAError, syslog, resolve rt2jira_regex = re.compile('From: rt2jira\n') action_regex = re.compile('Action: (.*)\n') tid_regex = re.compile('Ticket ID: (.*?)(\r|)\n') # Get the set of tickets that have been inactive for a set amount of time. jira_results = jira.search_issues( 'project = ' + config.get('jira', 'project') + ' AND component = "' + config.get('jira', 'component') + '" AND status in ("Open") AND createdDate <= startOfDay(-' + config.get('jira', 'auto_resolve_after_days') + 'd) ORDER BY created ASC', maxResults=False) try: for jira_issue in jira_results: logger.info('Processing Ticket (' + jira_issue.key + ')') syslog.syslog(syslog.LOG_INFO, 'Processing Ticket (' + jira_issue.key + ')') # Next, obtain all current comments on the JIRA ticket. jira_comments = jira.comments(jira_issue) ticket_acted_upon = False for existing_comment in jira_comments: action_match = action_regex.search(existing_comment.body) tid_match = tid_regex.search(existing_comment.body)