Is it possible to change jira issue status with python-jira?

wind picture wind · Nov 13, 2013 · Viewed 17.9k times · Source

I want to change jira issue status with python-jira.The python-jira API is http://jira-python.readthedocs.org/en/latest/ .I can't find any way to do this. I was trying to use issue.update(status="Closed").But it didn't work.I found Issue status and workflow in https://developer.atlassian.com/display/JIRADEV/Issue+status+and+workflow .But I still don't know what to do.Can anyone help me out?

Answer

TkTech picture TkTech · Nov 13, 2013

I ran into this as well, and unfortunately JIRA's incredible flexibility also makes it a PITA sometimes.

To change the status on a ticket, you need to make a transition, which moves it from one status to the next.

You need to find your transition IDs, then use it like so:

if issue.fields.status in ('open', 'reopened'):
    # Move the ticket from opened to closed.
    jira.transition_issue(ticket, transition='131')

jira-python documents discovering and making transitions here.

jira.transition_issue is documented here. You can actually use the name (ex: 'Closed') of the transition instead of the ID, but the ID is more reliable as it will not change.