zaterdag 24 april 2010

Using Groovy for reading your Jira database

Jira in combination with Greenhopper is a very popular tool. See this link to see a list of agile tools.

Sometimes however some additional magic and customisation is needed with your Jira issues. For this the xml-rpc interface that Jira offers can be very useful. One way to use this interface in an easy way is, of course, Groovy.

After browsing a little I found this document to be very useful. Don't forget to put the groovy xml-pc jar in your $HOME/.groovy/lib directory (more info on  Groovy-XMLRPC page). My first start is this script:

import groovy.net.xmlrpc.XMLRPCServerProxy as Proxy

def proxy = new Proxy('http://jira.codehaus.org/rpc/xmlrpc')
def loginToken = proxy.jira1.login('...','...')

def issue = proxy.jira1.getIssue(loginToken, 'GMOD-85')
issue.each{ key, value ->
    println key
}

println issue.summary
println issue.status
println issue.reporter

def user = proxy.jira1.getUser(loginToken, "ben.schreur")
println user

def projects = proxy.jira1.getProjectsNoSchemes(loginToken)
projects.each{ project ->
    println project.name
}

This is just the beginning as a will be doing some more Jira scripting on my current job. Better to automate as much as possible when going through bug-databases is needed. If you like to read more scripts on Jira just drop a comment.

Cheers!

Update March 26th: Jira does not allow access to the amount of estimated hours via xmlrpc. It does however work via soap. An update will follow. :-)