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?
You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. def change_grade_status(request, course_slug, activity_slug, userid): """ Grade status form. Calls numeric/letter view as appropriate.
To update the status, you need to use the Transition issue. You can edit an issue using the Edit issue API. The fields that can be edited are determined using Get edit issue metadata.
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.
To change status, you need to do transaction above the issue. Transition is just operation that is defined in 'workflow', and transit issue from one status to another. From current status you can perform just limited set of transition, that depends on 'workflow'. Try to use following functions: Current issue status:
issue = jira.issue('PROJECT-1')
issue.fields.status
JIRA Status: name='Fix submitted', id='10827'
Possible transitions for current status of the issue:
jira.transitions(issue)
[{'id': '181', 'name': 'Fix Failed', 'to': ..........}}}, {'id': '261', 'name': 'Fix Verfied', 'to': {'self':.....}}}]
So then you can perform two transitions:
jira.transition_issue(issue, transition='Fix Failed')
or
jira.transition_issue(issue, 261)
Then you can verify that your issue changed status on the server:
issue = jira.issue('PROJECT-1')
issue.fields.status
JIRA Status: name='Fix failed', id='10830'
So, in answer of your question, you need to perform more transition to transfer issue from one state to another if states are not connected by transition. eg.: Consider workflow from this url and your issue current state is "RESOLVED", and let say you want to achieve status "IN PROGRESS". Similar code can be used:
jira.transition_issue(issue, transition='Reopen Issue')
jira.transition_issue(issue, transition='Start Progress')
Here is the code for updating the status of Jira issue via Python:
from jira import JIRA
JIRA_SERVER = "https://issues.your-company.com/"
jira_user_name = "your_user_name"
jira_password = "your_jira_password"
jira_connection = JIRA(basic_auth=(jira_user_name, jira_password),
server=JIRA_SERVER)
jira_connection.transition_issue("PR-1309", "Start Progress")
Here PR-1309 is the ID of your JIRA Issue. Start Progress is the action that needs to be taken for this issue. The list of actions can be different for different customers of JIRA. Therefore, open your JIRA Portal and see the available transition options for your JIRA issues. Some transition actions can be:-
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With