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.
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
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.
And then take that output and drop it in here : http://jsonviewer.stack.hu
resulting in something like ....
"name": "To Do",
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();
Badges are a great way to show off community activity, whether you’re a newbie or a Champion.Learn more
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG