这是 Atlassian Jira 8.0.0 或更高版本的完整解决方案。
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.RendererManager;
import com.atlassian.jira.issue.fields.renderer.JiraRendererPlugin;
import com.atlassian.jira.issue.fields.renderer.IssueRenderContext;
public String renderWikiMarkupOfDescription(String descriptor, Issue issue) {
RendererManager rendererManager = ComponentAccessor.getComponentOfType(RendererManager.class);
JiraRendererPlugin renderer = rendererManager.getRendererForType("atlassian-wiki-renderer");
String output = renderer.render(descriptor, new IssueRenderContext(issue));
return output;
}
public String renderWikiMarkupOfEnvironment(String environment, Issue issue) {
RendererManager rendererManager = ComponentAccessor.getComponentOfType(RendererManager.class);
JiraRendererPlugin renderer = rendererManager.getRendererForType("atlassian-wiki-renderer");
String output = renderer.render(environment, new IssueRenderContext(issue));
return output;
}
和用法:
renderWikiMarkupOfDescription(issue.getDescription(), issue);
renderWikiMarkupOfEnvironment(issue.getEnvironment(), issue);
和截图来证明这个工作 100% 成功: