Created
May 12, 2011 08:12
-
-
Save jcsirot/968147 to your computer and use it in GitHub Desktop.
JIRA with Groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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