Skip to content

Instantly share code, notes, and snippets.

@jcsirot
Created May 12, 2011 08:12
Show Gist options
  • Save jcsirot/968147 to your computer and use it in GitHub Desktop.
Save jcsirot/968147 to your computer and use it in GitHub Desktop.
JIRA with Groovy
import groovy.net.xmlrpc.XMLRPCServerProxy as Proxy
class JiraProxy extends Proxy {
protected final token
JiraProxy(url, login, password) {
super(url)
this.token = super.invokeMethod("jira1.login", [login, password])
}
Object invokeMethod(String methodname, args) {
super.invokeMethod('jira1.' + methodname, [token] + args.toList())
}
}
String.metaClass.getProperty = { String p ->
def jira = new JiraProxy('http://issues.myproject.com/rpc/xmlrpc', 'login', 'password')
def metaProperty = String.metaClass.getMetaProperty(p)
def result
if (metaProperty) {
result = metaProperty.getProperty(delegate)
} else {
switch (p) {
case "comments":
result = jira.getComments(delegate)
break;
default:
result = jira.getIssue(delegate).get(p)
break;
}
}
result
}
// Get a specific issue
println 'ISSUE-42'.description
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment