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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Creating Section and Columns using Jira MarkupBuilder with Structured Macro Edited

I am new in Jira and I am creating a post-function that will create a Confluence Page.

I want to write the storage format using an XML builder and I have the following code.


// write storage format using an XML builder
def writer = new StringWriter()
def xml = new MarkupBuilder(writer)

xml.'ac:structured-macro'('ac:name': "section") { 'ac:parameter'('ac:name': "border","true") 'ac:parameter'('ac:name': "width","100") xml.p("This is a Section") xml.'ac:structured-macro'('ac:name': "column") { 'ac:parameter'('ac:name': "border","true") xml.p("This is a Column") } }

// print the storage that will be the content of the page
log.debug(writer.toString())

My goal is to create a section with a column using a structured macro but it is not working as expected as it only creates the Section part.

1 answer

1 accepted

1 vote
Answer accepted

I think you are missing the body containers.

Try it like this:

import groovy.xml.MarkupBuilder
def writer = new StringWriter()
def xml = new MarkupBuilder(writer)

xml.'ac:structured-macro'('ac:name': "section") {
'ac:parameter'('ac:name': "border","true")
'ac:rich-text-body'{
xml.p("This is a Section")
xml.'ac:structured-macro'('ac:name': "column") {
'ac:parameter'('ac:name': "width","100")
'ac:rich-text-body'{
xml.p("This is a Column")
}
}
}
}
log.info writer.toString()

If you don't already, I'd recommend getting https://marketplace.atlassian.com/plugins/com.atlassian.confluence.plugins.editor.confluence-source-editor?_ga=2.251717833.1701738042.1579542961-924046337.1569864105

This way to can output your xml, and paste it directly in a page to test it.

Or edit a page and see the resulting xml immediately (and edit it if necessary)

Thank you so much! It is now working as expected. 

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you