I'm trying to access jira in ruby with the Jira-ruby gem (https://rubygems.org/gems/jira-ruby), but i can't find how to change the transitions. I can only change it using the REST-api?
There is a Transition class (http://rubydoc.info/gems/jira-ruby/0.1.8/JIRA/Resource/Transition), but i don't know how to deal with it.
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.
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