Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fetching entire changelog for an issue in JIRA using jira-python

Using jira-python, I want to retrieve the entire changelog for a JIRA issue:

issues_returned = jira.search_issues(args.jql, expand='changelog')

I discovered that for issues with more than 100 entries in their changelog I am only receiving the first 100:

Screenshot from debugger

My question is how do I specify a startAt and make another call to get subsequent pages of the changelog (using python-jira)?

From this thread at Atlassian I see that API v3 provides an endpoint to get the change log directly:

/rest/api/3/issue/{issueIdOrKey}/changelog

but this doesn't seem to be accessible via jira-python. I'd like to avoid having to do the REST call directly and authenticate separately. Barring a way to do it directly via jira-python, is there a way to make a 'raw' REST API call from jira-python?

like image 790
John Carter Avatar asked Oct 20 '25 05:10

John Carter


1 Answers

I'm not sure if the package / API got changed since the accepted answer, but it is not true anymore. I tested it today:

The startAt parameter only relates to the offset concerning the number of issues, not the changelog.

On a positive note, with expand="changelog" enabled the request seemingly returns all the changes at once for an issue anyway. I was able to test this with a changelog of 34.822 changes.

The parameter startAt has no influence on the number or offset of items in the changelog.

Full code example:

import jira
jira_client = jira.JIRA(JIRA_URL, token_auth=api_token)
return_value = jira_client.search_issues(
    jql_str=f"issue = {issue_key}",
    json_result=True,
    fields=["None"],
    expand="changelog",
)
return return_value["issues"][0]["changelog"]["histories"]
like image 95
Cribber Avatar answered Oct 21 '25 19:10

Cribber



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!