I'm trying to use the python interface to transition the state of a set of issues in an automated fashion.
It's lless than clear to me how to even get an issue to go from say an open state to a todo or further in the the workflow.
jira.transition_issue(issue, '10000')
10000 came from jirashell and printing out the issue.fields.status.id value of a card which I'd taken from the open to the todo state. So by the logic I ought to be able via python to take a card in an open state and likewise transition it to 10000, aka todo. It fails with:
the error :
File "/usr/local/lib/python2.7/site-packages/jira/client.py", line 93, in wrapper
result = func(*arg_list, **kwargs)
File "/usr/local/lib/python2.7/site-packages/jira/client.py", line 1098, in transition_issue
url, data=json.dumps(data))
File "/usr/local/lib/python2.7/site-packages/jira/resilientsession.py", line 81, in post
return self.__verb('POST', url, **kwargs)
File "/usr/local/lib/python2.7/site-packages/jira/resilientsession.py", line 74, in __verb
raise_on_error(r, verb=verb, **kwargs)
File "/usr/local/lib/python2.7/site-packages/jira/utils.py", line 120, in raise_on_error
r.status_code, error, r.url, request=request, response=r, **kwargs)
jira.utils.JIRAError: JiraError HTTP 500
text: Internal server error
Here's the python solution, which is what I'm working with. The transition IDs are part of the Workflow view, but not everyone can see those IDs. In my case I can see the graph but JIRA doesn't actually display what the IDs are in order to make it work.
So one must do a little reverse engineering.
If you visit : https://your.url.here/rest/api/2/issue/SOMEISSUE-XX/transitions
And then take that output and drop it in here : http://jsonviewer.stack.hu
resulting in something like ....
"id": "811",
"name": "To Do",
"to": {
....
You'll note that for the start of each section is an id and a number. Those are the numbers that you need and they CAN be different so you'll want to look at an issue in every one of the states and dump out their transitions to see what the ids are.
So for me
jira.transition_issue(issue, '811') moves an object from Open to ToDo.
Now I will mention that you ought to be able to get this info out of jira.transitions(issue) but alas my Python isn't that great and that object that comes back it wasn't obvious to me how to walk through the structure....
Try something like this:
import com.atlassian.jira.workflow.WorkflowTransitionUtil; import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl; import com.atlassian.jira.util.JiraUtils; import com.atlassian.crowd.embedded.api.User; WorkflowTransitionUtil workflowTransitionUtil = ( WorkflowTransitionUtil ) JiraUtils.loadComponent( WorkflowTransitionUtilImpl.class ); workflowTransitionUtil.setIssue(issue); workflowTransitionUtil.setUsername(user); workflowTransitionUtil.setAction (101); // 101 == Transition ID workflowTransitionUtil.validate(); workflowTransitionUtil.progress();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.