How to automatically add HTML content to Confluence
Asked by nikhil khedlekar:

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!  
[](https://community.atlassian.com/t5/Confluence-questions/How-to-automatically-add-HTML-content-to-Confluence/qaq-p/249974?attachment-id=10458){#link_11912a91b6cde9}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/42229/1/Sample%20documentation%20HTML.jpg){#display_11912a91b6cde9_0}  
[](https://community.atlassian.com/t5/Confluence-questions/How-to-automatically-add-HTML-content-to-Confluence/qaq-p/249974?attachment-id=10459){#link_11912a91b6cde9_0}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/42229/2/image2016-1-21%2013%3A45%3A31.png){#display_11912a91b6cde9_2}


Answers:
author: Bob Swift (personal)
body: You can use **CLI task** from [Run CLI Actions in Bamboo](https://bobswift.atlassian.net/wiki/display/BCLIP) to run the [storePage](https://bobswift.atlassian.net/wiki/display/CSOAP/Reference#Reference-storePage) action from [Confluence CLI](https://bobswift.atlassian.net/wiki/display/CSOAP) 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}"
```

comments: author: nikhil khedlekar
body: 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


author: Bob Swift (personal)
body: 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.


author: nikhil khedlekar
body: Thats an interesting idea. Let me try it out.


author: nikhil khedlekar
body: Hi Bob. Which of these should I use?

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


author: Bob Swift (personal)
body: 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.


author: Steven F Behnke
body: 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.

comments: author: nikhil khedlekar
body: 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](http://172.26.44.76: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"


author: Steven F Behnke
body: 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?


author: nikhil khedlekar
body: 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)


author: Steven F Behnke
body: 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 --

```
&lt;iframe src="http://www.atlassian.com/" noborder="0" width="830" height="800" scrolling="yes" seamless&gt;&lt;/iframe&gt;
```

A usermacro would further simplify this.


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


Tags: html