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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,644,405
Community Members
 
Community Events
196
Community Groups

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

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

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