Using the JIRA Soap interface from Ruby
There’s is surprisingly little documentation about calling into the JIRA bug tracking system from Ruby using the JIRA Soap interface.
I had to jump through quite a few hoops to make this work. Here’s what I did, to try to spare you the same pain. (There are a few missing details that I’ll reconstruct via more Google searches if anyone is really interested.)
1. I used the wsdl2rb tool to generate a Ruby wrapper interface based on the wsdl file from Ruby. Ruby ships with the soap4r, the soap interface, but it doesn’t actually ship with the batch file wrapper, so I had to download that separately. (URL findable via Google.)
2. There was a bug in soap4r that prevented it from handling the WSDL file correctly, so I had to install a patch to fix that bug.
3. There are few if any examples of using the complex types in the SOAP interface from Ruby. Python seems to automatically convert simple hash tables to structured types, but Ruby’s SOAP interface will give a type error unless you use the appropriate class wrappers. Almost through trial and error, I worked out the following, which does work.
#!/usr/bin/env ruby
require 'defaultDriver.rb'
obj = JiraSoapService.new()
token = obj.login("test", "test")
field = RemoteFieldValue.new('summary',
['[Updated] Issue updated with Ruby'])
obj.updateIssue token, 'JOB-6562', [field]
4. Unfortunately, I found Atlassian’s developer forums and documentation a little hard to search and navigate, at least for answering this question. I’m posting it to this blog rather than the forums because I have greater confidence that someone one will be able to find it.
Now that it’s finally working, I’m pretty excited about the ability to script and automate JIRA from external tools.