Accessing Jira from Ruby
Soap4R and Jira4R
On Ubuntu I've installed ruby, the interactive Ruby shell irb and rubygems through apt-get and performed a gem update:
apt-get install ruby irb rubygems ruby1.8-dev gem update --system
Gem is to Ruby what apt-get is to Ubuntu and Debian or CPAN to Perl: A package manager with support for dependencies providing and easy way to install extensions.
As with Java I prefer to us the native tools of the language to manage libraries and extensions so I only used apt-get to install the base and added the remaining dependencies through gem:
gem install rake gem install soap4r
Rake is Ruby's make or ant and allows to build applications from source. Soap4R is a soap library for Ruby.
Now it's time to install Jira4R. I've used the latest version from their subversion repository:
cd /usr/local/src svn co http://svn.rubyhaus.org/jira4r/trunk/ jira4r cd jira4r gem build jira4r.gemspec gem install *.gem
Using Jira4R is quite simple:
require 'rubygems'
require 'jira4r/jira_tool'
jira = Jira4R::JiraTool.new(2, "http://jira.atlassian.com")
jira.login("soaptester", "soaptester")
issue = Jira4R::V2::RemoteIssue.new
issue.project = "DEMO"
issue.type = "1"
issue.summary = "Test from Ruby"
issue.assignee = "soaptester"
jira.createIssue(issue)
You can find more examples on the Jira4R page and in Jira's SOAP API.
If you access your Jira instance through SSL you can add
jira.driver.options["protocol.http.ssl_config.verify_mode"] = nil
before the call to login so that Soap4R does not try to verify the SSL certificate. If you don't you will encounter errors like
.../httpclient.rb:1039:in `connect': certificate verify failed (OpenSSL::SSL::SSLError)