Created
May 8, 2017 21:12
-
-
Save ahplummer/9a3fd1db7cba57fb07f0f56678fd27b5 to your computer and use it in GitHub Desktop.
Paginates the JIRA API for issue retrieval
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
def RetrieveJiraIssuesPaginate(baseurl, key, user, password, maxper): | |
retval = [] | |
base64string = base64.encodestring('%s:%s' % (user, password)).replace('\n', '') | |
maxResults = maxper | |
startAt = 0 | |
total = 0 | |
keepgoing = True | |
while keepgoing: | |
url = baseurl + '/rest/api/2/search?jql=project=' + key + '&maxResults=' + str(maxResults) + '&startAt=' + str(startAt) | |
request = urllib2.Request(url) | |
request.add_header("Authorization", "Basic %s" % base64string) | |
response = urllib2.urlopen(request) | |
rs = json.load(response) | |
totalrecs = rs['total'] | |
for issue in rs['issues']: | |
total += 1 | |
retval.append(issue['key']) | |
print issue['key'] | |
startAt += maxResults | |
if total >= totalrecs: | |
keepgoing = False | |
return retval |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment