Created
June 9, 2015 18:10
-
-
Save looprock/59ce177b6f4503076b16 to your computer and use it in GitHub Desktop.
errbot jira integration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@botcmd(split_args_with=None) | |
def tickets(self, mess, args): | |
"""list jira tickets - options: -user=[def: you], -status=[RE: Closed], -project=[RE: Operations] -search=[string]""" | |
options = {'server': 'https://jira.company.com'} | |
user = utils.get_sender_username(mess) | |
status = '(status = Open OR status = Reopened OR status = "In Progress")' | |
tmpstatus = None | |
#project = "Operations" | |
project = None | |
search = None | |
for arg in args: | |
if re.match(r'-user=', arg): | |
user = arg.split("=")[1].strip() | |
if re.match(r'-status=', arg): | |
tmpstatus = arg.split("=")[1].strip() | |
if re.match(r'-project=', arg): | |
project = arg.split("=")[1].strip() | |
if re.match(r'-search=', arg): | |
search = arg.split("=")[1].strip() | |
names = { | |
"tom": "tomjones", | |
"allen": "aturing", | |
"sid": "svicious", | |
} | |
if tmpstatus: | |
status = "status = %s" % (tmpstatus) | |
if len(user.split()) > 1: | |
user = user.split()[0] | |
if user.lower() in names.keys(): | |
user = names[user.lower()] | |
jira = JIRA(options, basic_auth=('errbot', 'YOURPASSWORDHERE')) | |
sstring = '%s AND assignee=%s' % (status, user) | |
if project: | |
sstring += " AND project=%s" % (project) | |
if search: | |
sstring += " AND text ~ %s" % (search) | |
ops = jira.search_issues('%s' % (sstring), maxResults=False) | |
tickets = "" | |
yield "Search: %s" % (sstring) | |
for issue in ops: | |
tickets += "https://jira.vast.com/browse/%s - %s - %s\n" % (issue,issue.fields.status,issue.fields.summary) | |
tickets += "Total tickets: %s" % str(len(tickets.split("\n")) - 2) | |
yield tickets |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment