JIRA Scriptrunner - Using Confluence Rest API to pull data from Confluence into a JIRA field

Aaron Andrade April 17, 2018

Goal

Pull a list of contacts documented in Confluence (part of page properties macro (id=contacts, key=Outage Contact List)) and make available in a custom field (type multi-select) in JIRA

What I have

I have a URL that uses Confluence's Rest API along with a sample output of what I get back.

https://confluence.domain.com/rest/masterdetail/1.0/detailssummary/lines?cql=type%3Dpage&detailsId=contacts&sortBy=title&spaceKey=CONTACTS&contentId=123445&headings=Outage%20Contact%20List
{
  "currentPage": 0,
  "totalPages": 17,
  "renderedHeadings": [
    "Outage Contact List"
  ],
  "detailLines": [
    {
      "id": 209718035,
      "title": "ABC Contacts",
      "relativeLink": "/display/ABC/ABC+Contacts",
      "details": [
        "<p xmlns=\"http://www.w3.org/1999/xhtml\"><span><a class=\"external-link\" href=\"mailto:Person.A@client.com\" rel=\"nofollow\">Person.A@client.com</a></span></p>"
      ],
      "likesCount": -1,
      "commentsCount": -1
    },
  ],
  "asyncRenderSafe": true
}

What I need from the GET

I need the "details" Person.A@client.com... There are multiple sets returned in "detailLines", but all I want is "details".

What I have referenced

What I don't know

  • I am not savvy enough with the code to pull it all together, in JIRA.  1) Call Confluence, 2) Parse the data, and 3) Assign to a custom field.  Any ideas or suggestions would be most helpful

1 answer

0 votes
Matt Doar
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 17, 2018

I think I'd use the nFeed plugin

Aaron Andrade April 18, 2018

I'll give it a try, but it requires funds that I'm not sure I'll be able to get soon. I am hoping to use plugins/add-ons we have already purchased.  At least I can prove it out technically.

Thanks--Michelle

Aaron Andrade April 18, 2018

Matt,

Are you a nFeed expert?  I cannot get the "details" field to produce anything.  Everything else under "detailLines" parses out beautifully (i.e. id, title, relativeLink, likesCount, and commentsCount).  I cannot get confluence to NOT add in the www address into the <p> field.

"<p xmlns=\"http://www.w3.org/1999/xhtml\">Person.A@client.com</p>"
Matt Doar
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 18, 2018

Suggest an answer

Log in or Sign up to answer