Skip to content

Instantly share code, notes, and snippets.

@rodrigofelix
Last active July 6, 2020 14:35
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save rodrigofelix/4a96d5b296c2a841b44fccf7773b82e0 to your computer and use it in GitHub Desktop.
Python script to calculate the number of Story Points closed for a given JIRA filter
from jira import JIRA
import getpass
# add your JIRA instance URL here
jiraURL = 'https://myjira.com'
# update with JIRA username or replace it with
# username = input('Type your JIRA username')
# to ask for the username in the command line
username = 'myusername'
try:
password = getpass.getpass(prompt='Type your JIRA password: ')
except Exception as error:
print('Error when getting password', error)
else:
jira = JIRA(jiraURL, basic_auth=(username, password))
try:
filterId = '27629'
filterJQL = jira.filter(filterId).jql
except Exception as error:
print('JIRA filter ' + filterId + 'is not available or does not exist')
else:
issues = jira.search_issues(filterJQL)
totalPoints = closedPoints = 0
for i in range(len(issues)):
fields = issues[i].fields
points = 0 if fields.customfield_10002 == None else fields.customfield_10002
totalPoints += points
closedPoints += 0 if fields.status.name != 'Closed' else points
percentage = 0 if (totalPoints == 0) else (closedPoints / totalPoints) * 100
print('Total points: ', totalPoints)
print('Closed points: ', closedPoints)
print('Closed %: ', round(percentage, 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment