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:
... 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.
Community moderators have prevented the ability to post new answers.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.