JIRA Integration

Last modified by Vincent Massol on 2021/03/18 11:28

cogShows different solutions to access JIRA from an XWiki instance
Developed by

Vincent Massol

0 Votes
LicenseGNU Lesser General Public License 2.1


There are several solutions to access data from your online JIRA server:

In addition to this you can simply use JIRA's RSS URLs as demonstrated below. Also make sure to check out the JIRA Macro which uses the JIRA RSS URLs.

If all you need is query the JIRA server using the JIRA's RSS URLs is by far the best method (it's also the more performant one). On the other hand if you need to make modifications to JIRA then you should use one of the other methods.


Displays the summary of an issue

def url = "http://jira.xwiki.org/si/jira.issueviews:issue-xml/XWIKI-1000/XWIKI-1000.xml".toURL().text
def root = new XmlSlurper().parseText(url)

println "${root.channel.item.summary}"

Displays the content of a list of issues

def jql = URLEncoder.encode("issueKey=XWIKI-1000 OR issueKey=XWIKI-1001", "UTF-8")
def columns = "field=type&field=key&field=summary&field=assignee&field=status&field=link"

def url = "http://jira.xwiki.org/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?jqlQuery=${jql}&${columns}".toURL().text
def root = new XmlSlurper().parseText(url)

println "|=Type|=Id|=Summary|=Assignee|=Status"
root.channel.item.each() {
    println "|[[image:${it.type.@iconUrl}]]|[[${it.key}>>${it.link}]]|${it.summary}|${it.assignee}|[[image:${it.status.@iconUrl}]]"



Computes total time spent

import groovy.json.*

def jql = "project = NUMPORTAL AND component = 17-002 AND component = 'Out of Scope'"
def url = "https://jira.xwikisas.com/rest/api/2/search?jql=${java.net.URLEncoder.encode(jql)}&os_username=<usernamehere>&os_password=<userpasswordhere>&os_authType=basic&field=timespent".toURL().text
def root = new JsonSlurper().parseText(url)

int totalTimespent = 0
root.issues.each() { issue ->
  def spent = issue.fields.timespent
 if (spent) {
    totalTimespent += spent
println "Total time spent = ${totalTimespent} seconds"
Tags: jira REST

Get Connected