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,552,588
Community Members
 
Community Events
184
Community Groups

JIRA field value over the confluence page along with style & formatting

Edited
Suresh Sakhare
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jul 22, 2021

Hi,

 

One of our customer requirement is to update the JIRA issue description value over the confluence page.

To get it done I implemented following solution with help of #ScriptRunner plugin.

  • Created Listener at JIRA end on issue update.
  • Created RestEnd point at confluence end to serve the request.
  • On issue update trigger, Sending API request to confluence along with update field  data in WIKI format.
  • Inside Rest API, capturing the WIKI data & converting it into storage format and updating the page. 
  • Prerequisite is JIRA issue should have confluence page link.

Below is the Sample code to convert WIKI data into storage format. Written in script console.

import com.atlassian.confluence.content.render.xhtml.ConversionContext
import com.atlassian.confluence.content.render.xhtml.DefaultConversionContext
import com.atlassian.confluence.xhtml.api.XhtmlContent
import com.atlassian.confluence.pages.Page
import com.atlassian.confluence.core.DefaultSaveContext
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.pages.PageManager
import org.apache.commons.lang.StringUtils
import com.atlassian.confluence.core.ContentEntityObject

PageManager pagemanager = ComponentLocator.getComponent(PageManager);
XhtmlContent xhtmlContent = ComponentLocator.getComponent(XhtmlContent);

try{
Page page = pagemanager.getPage(75990487);
ContentEntityObject contentEntityObject = page.getBodyContent().getContent();

final List<RuntimeException> wikiMarkupToStorageConversionErrors = new ArrayList();

final ConversionContext conversionContext = new DefaultConversionContext(page.toPageContext())
String jiraText = "Hi\r\n\r\n \r\n\r\nThis is +created+ for{color:#de350b}[SolutionBook|https://solutionbook.xxxx.com/]{color} testing purpose. _Please ignore._ \r\n||*JIRA*||Confluence||\r\n|Test|Best|\r\n\r\n \r\n :)\r\n * 1\r\n * 2\r\n * 3\r\n\r\n-Test-\r\n{code:java}\r\n{java code}{code}\r\n{panel}\r\n*Panel Header*\r\n\r\nPanel Text\r\n{panel}\r\n{noformat}\r\n*no* further _formatting_ is done here{noformat}\r\naksdfhasdf"
String jiradata = xhtmlContent.convertWikiToStorage(jiraText,conversionContext,wikiMarkupToStorageConversionErrors)
String pageBody = page.getBodyAsString()

pageBody = pageBody.replace("suresh",jiradata);

page.setBodyAsString(pageBody);
pagemanager.saveContentEntity(page,null);
return "pageBodyStr"
}catch(e){
log.error("Something went wrong whilw updating toc parameter:"+e.getMessage());


}

 

 

0 comments

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events