Simple Ruby library for accessing JIRA by XML-RPC
| Name | jira4r |
|---|---|
| Version | 1.0 |
| Author(s) | Charles Miller |
| Home Page | http://www.atlassian.com/ |
| Download Location | jira4r.rb |
Description/Features
A quick hack on confluence4r, jira4r streamlines accessing JIRA's XML-RPC services through Ruby. The basic library is very simple, just allowing access to existing XML-RPC methods. See jiralib4r for some add-on functionality.
require 'xmlrpc/client' # A useful helper for running JIRA XML-RPC from Ruby. Takes care of # adding the token to each method call (so you can call server.getIssue(key) # instead of server.getIssue(token, key)). Also takes care of re-logging in # if your login times out. # # Usage: # # require 'jira4r' # server = JIRA::Server.new("http://jira.atlassian.com") # server.login("user", "password") # puts server.getIssue("JRA-1000") # module JIRA class Server def initialize(server_url) server_url += "/rpc/xmlrpc" unless server_url[-11..-1] == "/rpc/xmlrpc" @server_url = server_url server = XMLRPC::Client.new2(server_url) @jira = server.proxy("jira1") @token = "12345" end def login(username, password) @user = username @pass = password do_login() end def method_missing(method_name, *args) begin @jira.send(method_name, *([@token] + args)) rescue XMLRPC::FaultException => e if (e.faultString.include?("RemoteAuthenticationException")) do_login retry else raise e.faultString end end end private def do_login() begin @token = @jira.login(@user, @pass) rescue XMLRPC::FaultException => e raise e.faultString end end end end
