Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

In a JIRA script, how do I render wiki text fields?

d July 16, 2013

I have a Jython script which sends emails. Basically, stuff like:

from com.atlassian.jira import ComponentManager
from com.atlassian.jira.issue import CustomFieldManager
from com.atlassian.jira.issue.fields import CustomField
cfm = ComponentManager.getInstance().getCustomFieldManager()

change_summary = issue.getCustomFieldValue(cfm.getCustomFieldObjectByName("Change Summary"))

# Build a multipart email with text and html from template, and send it ...

Now, the trick is, the Change Summary custom field is configured for wiki text rendering. If at all possible, I would want to render that into text or html for the various parts.

Shopping around the API, it looks like I want to work from here:

https://docs.atlassian.com/jira/latest/com/atlassian/jira/issue/fields/renderer/JiraRendererPlugin.html

... using render() for HTML and renderAsText() for text? I can probably figure this out, but if anyone can point to some existing example code, I would be most grateful.

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
d July 17, 2013

Answer is actually over here: https://answers.atlassian.com/questions/135084/method-to-convert-jira-wiki-format-to-html

Here is what Jython would look like:

from com.atlassian.jira.component import ComponentAccessor
from com.atlassian.event.api import EventPublisher
from com.atlassian.jira.util.velocity import VelocityRequestContextFactory
from com.atlassian.jira.issue.fields.renderer.wiki import AtlassianWikiRenderer
eventPublisher = ComponentAccessor.getOSGiComponentInstanceOfType(EventPublisher)
velocityRequestContextFactory = ComponentAccessor.getOSGiComponentInstanceOfType(VelocityRequestContextFactory)
wikiRenderer = AtlassianWikiRenderer(eventPublisher, velocityRequestContextFactory)

change_summary_html = wikiRenderer.render(change_summary, None)
change_summary_text = wikiRenderer.renderAsText(change_summary, None)

TAGS
AUG Leaders

Atlassian Community Events