How to change transitions to a issue in ruby, using jira-ruby gem?

≯℡__Kan透↙ 提交于 2019-12-05 14:42:19

The REST API docs say that you POST to /issue/{issueIdOrKey}/transitions to transition an issue from one status to another.

First fetch the available transitions for an issue:

client = JIRA::Client.new( ... )
issue = client.Issue.find("PROJECT-123")
available_transitions = client.Transition.all(:issue => issue)
available_transitions.each {|ea| puts "#{ea.name} (id #{ea.id})" }

Now you have the names and ids of possible transitions. Store the id of the transition you want to make. Then use it to save a new transition for the issue:

transition_id = ...
transition = issue.transitions.build
transition.save!("transition" => {"id" => transition_id})

I had to check the docs a few times to understand the expected payload was for the POST transition call and then fiddle with the Ruby client syntax to get that payload. Using a tool like net-http-spy made it easier.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!