I swear I once saw in Atlassian docs that when requesting fields via Rest, one could add a “.html” or similar suffix to obtain the field value as rendered HTML, but can find that page anymore.
However, so far I always used the Jira Macro to get a list of issues, their key, priority, title etc and that works pretty well.
For a new task, I’d like to retrieve the description too, but I saw that adding “description” to the field list, the raw HTML is retrieved from Jira, not very useful esp. if the issue contains code blocks, images, and so forth.
Is there a way to get the rendered description?
I’m using the Jira Macro to ultimately embed a list of issues in a document to be sent externally by email.
Thank you. Going the Java way would require a lot of time, so I’d like to keep it as last option; I’m trying the wiki component option described there.
After the following changes, I got the example link working.
I added the XObject properties to the same page where the Jira Macro is used, I don’t know if that makes any difference;
the ComponentClass object had to have the scope set to Global instead of Current Wiki, otherwise it wouldn’t be applied, it seems (but this may be a side effect of #1)
the new type usage {{jira ... fields="..., somefield:lien, ..."}}...{{/jira}} had to be changed to {{jira ... fields="..., somefield!lien, ..."}}...{{/jira}}, so using !, because : is to specify the field label
the code block:
def field = xcontext.method.input.get(0)
def issue = xcontext.method.input.get(1)
String text = xcontext.method.defaultDisplayer.displayField(field, issue).get(0).getProtectedString()
to
def field = xcontext.method.input.get(0)
def issue = xcontext.method.input.get(1)
def parameters = xcontext.method.input.get(2)
String text = xcontext.method.defaultDisplayer.displayField(field, issue, parameters).get(0).getProtectedString()
otherwise the following exception would come out:
org.xwiki.component.wiki.WikiComponentRuntimeException: Failed to convert result [Failed to execute the [groovy] macro. Cause: [No signature of method: org.xwiki.contrib.jira.macro.internal.displayer.field.DefaultJIRAFieldDisplayer.displayField() is applicable for argument types: (org.xwiki.contrib.jira.macro.JIRAField, org.jdom2.Element) values: [id = [summary], label = [Summary], type = [lien], [Element: <item/>]] Possible solutions: displayField(org.xwiki.contrib.jira.macro.JIRAField, org.jdom2.Element, org.xwiki.contrib.jira.macro.JIRAMacroParameters)].
Almost, I saw that the description field from Jira issues is already retrieved in HTML, hence I guess that I need to send it to the HTML macro before returning from the method code.
Copying from the examples in the extension page, I got that:
Images in Jira issues do not get rendered, because they generate a 302 to Jira authentication page (which makes sense), do you know if there’s any setting in Jira or way to attach images or anything that can help with this?
Indeed, not easy if your jira instance is protected. You could ask on the jira support forums if there’s a way to get the image embedded in the returned content (using Data URI for example).
An alternative (complex) would be to parse the returned HTML to find the URLs and then issue several HTTP requests (using the jira credentials provided) to download the images and replace the <img> URL attribute to be something like <img src="data:image/gif;base64,.... However, this will be complex, costly and slow IMO.