Skip to content

Instantly share code, notes, and snippets.

@amcclosky
Created June 7, 2012 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save amcclosky/2890707 to your computer and use it in GitHub Desktop.
Save amcclosky/2890707 to your computer and use it in GitHub Desktop.
Pulls your currently "In Progress" tasks from a JIRA instance.
!/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