How to automatically add HTML content to Confluence

nikhil khedlekar January 20, 2016

In our CD pipeline which we have implemented using JIRA and Bamboo, we have an "automatic release notes generator" that generates the release notes for us in the working directory of the build on the bamboo server. We are looking to integrate this with Confluence.

Our requirement is to update these auto generated release notes in our Confluence instance automatically. The key here is that the content that is auto generated is in HTML format.

We are not sure what is the best solution to get this HTML content into Confluence. Please help!

3 answers

1 accepted

0 votes
Answer accepted
Bob Swift OSS (Bob Swift Atlassian Apps)
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.
January 20, 2016

You can use CLI task from Run CLI Actions in Bamboo to run the storePage action from Confluence CLI to create the page. If the data is HTML, I would recommend you wrap the HTML content in the html macro on your Confluence installation. Here is an example of the action you would use. The page content is constructed from the content parameter followed by the file contents followed by the value of the content2 parameter:

--action storePage --space XXX --title "My page title" --file page.html --content "{html}" --content2 "{html}"
nikhil khedlekar January 21, 2016

Bob: Thanks for responding.

Your CLI certainly looks very promising and we definitely want to consider it for purchase. 

In the above example I notice that you are passing "page.html" as one argument. But what if my HTML content is not merely one page. And there are other artifacts involved such as PNGs, javascript, etc. See below for example. Any help on how that can be handled ?

Sample documentation HTML.jpg

Bob Swift OSS (Bob Swift Atlassian Apps)
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.
January 21, 2016

You might want to just "serve" those pages directly using Confluence's Tomcat and simply put a single page in Confluence (perhaps the index???) in order to make it appear to be in Confluence and once they click on link it will just serve the regular HTML page. This would more easily retain the formatting of the generated stuff especially if it is more complex. I have done that with java doc like material in the (distant) past.

nikhil khedlekar January 21, 2016

Thats an interesting idea. Let me try it out.

 

nikhil khedlekar January 21, 2016

Hi Bob. Which of these should I use?

 

image2016-1-21 13:45:31.png

Bob Swift OSS (Bob Swift Atlassian Apps)
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.
January 21, 2016

Confluence Command Line Interface is what you need for your use case. It installs on your Confluence server and then you install a client - either the Confluence specific client or the more general Atlassian CLI client that includes all the other clients. There is no charge for clients, just the server piece is licensed.

0 votes
Steven F Behnke
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.
January 20, 2016

If you're attempting to display full HTML documents in Confluence, you may want to display pages in confluence that are rendering your documents – https://confluence.atlassian.com/doc/html-include-macro-169120653.html

You could use Bob Swifts CLI to programmatically create the pages as well.

nikhil khedlekar January 21, 2016

Steven

Thanks for responding.

I tried to use the HTML include macro. And the HTML page was not rendered fully. Only some text from the top showed up. So not sure how to proceed. 

Also - the HTML page that can be included - does it always have to sit behind a web server.

For example - if I have an HTML page that goes like this – http://1.2.3.4:8999/ops-util/devop2.html

and I use that in the HTML include macro

this is what I get "Error rendering macro 'html-include' : null"

 

Steven F Behnke
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.
January 21, 2016

Interesting. I've used it to display hosted pages, so I've never run into this issue like this.

If you'd still like to display content in a page, I'd probably instead create an iframe user macro and then load the content in to the iframe. That's really the effect you're trying to achieve anyway.

Seems like Bob's got a good handle on the basics of your question, the question of how to display other web content in Confluence is interesting. Again, an iframe is the effect you're looking for seemingly, is this something you could persue? Are you on Cloud or hosted? Are you an administrator?

nikhil khedlekar January 21, 2016

Yes. One of my responsibilities is to take care of all our DevOps tools and processes and related requirements. So in a way, I am an admin. Let me do some research on iframes as well. (We are on our own cloud by the way)

Steven F Behnke
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.
January 21, 2016

Well sure, you could use the HTML Include macro so you have access to Usermacros, duh.

You could enter the iframe into the HTML macro, like so – 

<iframe src="http://www.atlassian.com/" noborder="0" width="830" height="800" scrolling="yes" seamless></iframe>

 

A usermacro would further simplify this.

0 votes
nikhil khedlekar January 20, 2016

Just to clarify - the HTML content is not merely an HTML page, but includes stylesheets, PNGs, and angular JS

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events