-
-
Save viktor-evdokimov/4ef84b2620cc0d3f01fe to your computer and use it in GitHub Desktop.
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 python | |
# current-tasks.py | |
# author: Anthony McClosky - http://amcclosky.com | |
import requests | |
import json | |
JIRA_ROOT_URL = "jira.example.com" | |
JIRA_API_ENDPOINT = "http://%s/rest/api/2.0.alpha1/" % JIRA_ROOT_URL | |
USERNAME = "username" | |
PASSWORD = "pass" | |
def get_current_jira_tasks(username, password): | |
jql = "assignee = currentUser() AND status = \"In Progress\"" | |
data = {'jql': jql} | |
task_response = requests.get(JIRA_API_ENDPOINT + "search", params=data, auth=(username, password)) | |
search_results = json.loads(task_response.content) | |
issue_ids = [ issue.get('key') for issue in search_results.get('issues') ] | |
for issue_id in issue_ids: | |
issue_response = requests.get(JIRA_API_ENDPOINT + "issue/%s" % issue_id, auth=(username, password)) | |
issue = json.loads(issue_response.content) | |
data = { | |
'issue_id': issue_id, | |
'name': issue.get('fields').get('summary').get('value'), | |
'url': "http://%s/browse/%s" % (JIRA_ROOT_URL, issue_id) | |
} | |
print "[%(issue_id)s] %(name)s : %(url)s" % data | |
if __name__ == '__main__': | |
get_current_jira_tasks(USERNAME, PASSWORD) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment