JIRA support

Seo Sanghyeon sanxiyn at gmail.com
Sun Jul 5 05:00:00 UTC 2009


Inspired by the blog post by Sandro Tosi, I decided to hack on
bts-link this weekend.

Attached is a first stab at JIRA support. JIRA is used by some Apache
projects and Moodle. btslink.cfg entries are included. Since I use
JIRA's SOAP service, this patch adds python-soappy as an additional
dependency.

Please review! (I am not subscribed, please CC)

-- 
Seo Sanghyeon
-------------- next part --------------
diff --git a/btslink.cfg b/btslink.cfg
index 0e99afb..1b3a654 100644
--- a/btslink.cfg
+++ b/btslink.cfg
@@ -122,7 +122,7 @@ uri      = http://bugzilla.abisource.com
 type	 = bugzilla
 uri		 = https://bugzilla.andrew.cmu.edu
 
-[apache]
+[apache-bugzilla]
 type     = bugzilla
 uri      = http://issues.apache.org/bugzilla
 uri-re   = https?://issues.apache.org/bugzilla/show_bug.cgi\?id=([0-9]+)
@@ -788,3 +788,12 @@ closing	= closed
 wontfix	= wont-fix
 
 ;*************************************************************************}}}*
+; JIRA
+
+[apache-jira]
+type	= jira
+uri	= http://issues.apache.org/jira
+
+[moodle]
+type	= jira
+uri	= http://tracker.moodle.org
diff --git a/remote/base.py b/remote/base.py
index 8d1dbe0..dcc24e5 100644
--- a/remote/base.py
+++ b/remote/base.py
@@ -383,4 +383,4 @@ class RemoteBts:
         return data.id
 
 # Import all bugtracker classes which will in turn register with RemoteBts.register()
-import berlios, bugzilla, gnats, launchpad, mantis, rt, savane, sourceforge, trac, gforge, googlecode, roundup
+import berlios, bugzilla, gnats, launchpad, mantis, rt, savane, sourceforge, trac, gforge, googlecode, roundup, jira
diff --git a/remote/jira.py b/remote/jira.py
new file mode 100644
index 0000000..25d0021
--- /dev/null
+++ b/remote/jira.py
@@ -0,0 +1,55 @@
+# vim:set encoding=utf-8:
+
+# Copyright:
+#   © 2009 Sanghyeon Seo <sanxiyn at gmail.com>
+#
+# License:
+#   Public Domain
+
+# @see http://confluence.atlassian.com/display/JIRA/JIRA+RPC+Services
+
+# JIRA seems to require a user account to use its SOAP service.
+# Therefore, you need to create a user with ID bts-link, PW bts-link
+# before adding an entry to btslink.cfg. Sorry, this can't be automated.
+
+import SOAPpy
+
+from __init__ import *
+
+class JIRAData:
+    def __init__(self, bts, id):
+        issue = bts.soap.getIssue(bts.auth, id)
+
+        self.id = id or failwith(uri, 'JIRA: no id')
+        self.status = bts.status_map[issue.status]
+        self.resolution = None
+        if issue.resolution:
+            self.resolution = bts.resolution_map[issue.resolution]
+
+class RemoteJIRA(RemoteBts):
+    def __init__(self, cnf):
+        bugre = r'^%(uri)s/browse/([A-Z]+-[0-9]+)$'
+        urifmt = '%(uri)s/browse/%(id)s'
+        RemoteBts.__init__(self, cnf, bugre, urifmt, JIRAData)
+
+        uri = cnf['uri']
+        wsdl = uri + '/rpc/soap/jirasoapservice-v2?wsdl'
+        self.soap = SOAPpy.WSDL.Proxy(wsdl)
+        self.auth = self.soap.login('bts-link', 'bts-link')
+
+        self.status_map = {}
+        for status in self.soap.getStatuses(self.auth):
+            self.status_map[status.id] = status.name
+
+        self.resolution_map = {}
+        for resolution in self.soap.getResolutions(self.auth):
+            self.resolution_map[resolution.id] = resolution.name
+
+    def _getReportData(self, uri):
+        id = self.extractBugid(uri)
+        if not id: return None
+
+        data = JIRAData(self, id)
+        return data
+
+RemoteJIRA.register('jira', RemoteJIRA)


More information about the Bts-link-devel mailing list