Hacking JIRA with Ruby

March 19, 2009 at 10:13 pm | Posted in Programming | 8 Comments

I have been reading a lot over the last couple of months. Great books like “The World is Flat 3.0”, “Dreaming in Code”, “My Job went to India”, “The five dysfunctions of a team”, “Clean Code” and quite a few more. However I started to realize that although reading is fun, it tends to keep me in my comfort zone. I should really practice writing. People remember great writers. You hardly ever hear people saying “he was such a great reader” about a person that died hundred years ago.

So I just put down here what I’m doing at the moment. Lately I started to automate some things like writing progress reports for customers. Now please don’t stop reading at the word “progress report”. It might become a bit more interesting than you would expect. Part of my progress report consists of all kinds of metrics about a project: budgets, quality, schedule, etc. These metrics are collected from several systems and JIRA is one of them. Until recently I copied and pasted all this data into OpenOffice, did some magical calculations with a spreadsheet, and finally generated a few graphs which I used in the progress reports. So far the boring part.

However, JIRA also has a very nice RPC plugin which can be used to invoke JIRA operations remotely. And that’s exactly what I’m playing with at the moment. I’m using jira4r as a Ruby client library to automate all my tedious copy and paste actions. First experiments are succesful: with just a couple of lines (3 lines of code to be exact) of Ruby code I’m able to get a listing of all projects registered in a certain JIRA instance. Next step is to find a good library to generate graphs. Oh, and some actual code:


require 'rubygems'
require 'jira4r/jira_tool'

# Replace next url, username and password according to your own JIRA setup
jira = Jira4R::JiraTool.new(2, "http://jira.atlassian.com")
jira.login("soaptester", "soaptester")

# Dump all project descriptions
jira.getProjects.each { |project| puts project.description}

8 Comments »

RSS feed for comments on this post. TrackBack URI

  1. Ow just show the code. You can highlight it later. Good is good enough. Procrastinate not?

  2. @Seth: done šŸ™‚

  3. Hi Maurits,

    How’s life?

    Very interesting to read this šŸ™‚ I’ve been using Ruby quite a bit lately, and the company I’m working at now is also using Jira, so I think I’ll have a look into this. Look really interesting!

    Best regards,

    Arnaud

  4. Hi Maurits,Thanks for council, I will try to apply at myself.

  5. Giving following error,

    SOAP::FaultError: No such operation ‘getProjects’

    when I access,

    jira.getProjects.each { |project| puts project.description}

    Any idea ? is this method still there in JIRA api ?

  6. It’s 2012 and these libraries don’t install anymore. Any idea when this gets fixed?

    • The jira4r library seems pretty old and I have no idea if it’s still supported. Currently moving my own code to Clojure/ClojureScript.

  7. […] have previously written two posts about getting data from JIRA. In the first one I described how you can do that in Ruby. In the other one I used JavaScript to import JIRA data […]


Leave a reply to Extracting data from JIRA using Clojure and REST « Maurits thinks aloud Cancel reply

Blog at WordPress.com.
Entries and comments feeds.