Created
March 3, 2016 08:03
-
-
Save spoorcc/5fa8434be828d1d189b0 to your computer and use it in GitHub Desktop.
JIRA with python: proof-of-concept
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
#!/usr/bin/env python2 | |
# Use 'pip install jira' to install dependencies | |
from jira import JIRA, JIRAError | |
import argparse | |
MY_JIRA_SERVER = 'https://jira.somewhere.nl:port' | |
IS_THE_SSL_CERTIFICATE_FIXED = False | |
def login(username, password): | |
'''connects to Jira ''' | |
try: | |
jira = JIRA( server=MY_JIRA_SERVER, | |
options={'verify':IS_THE_SSL_CERTIFICATE_FIXED}, | |
basic_auth=(str(username), str(password))) | |
except JIRAError as e: | |
print(e.response) | |
jira = None | |
raise Exception('Login failed') | |
return jira | |
def parse_arguments(): | |
''' Get the command line arguments ''' | |
parser = argparse.ArgumentParser(description='Tool to get your work') | |
parser.add_argument('--username','-u', required=True) | |
parser.add_argument('--password','-p', required=True) | |
return parser.parse_args() | |
def get_last_weeks_issues(jira): | |
return jira.search_issues('timeSpent is not EMPTY AND updated > startOfWeek(-1) AND assignee was CurrentUser()') | |
def main(): | |
args = parse_arguments() | |
jira = login(args.username, args.password) | |
issues_since_last_week = get_last_weeks_issues(jira) | |
worklogs = [] | |
for issue in issues_since_last_week: | |
worklogs += [jira.worklogs(issue.key)] | |
print dir(worklogs[0]) | |
print(worklogs) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment