Jira Service Management integrates seamlessly with Confluence where it can be used for both external KB and internal communication and documentation.
Jira Service Management includes Jira Insights, which is a native asset and CI management tool.
One way that these three tools can work together is through a combination of JSM automation and the Confluence Rest API. JSM automation can look up objects in Jira Insights and using the API one can create a report on Asset changes, maintenance plans, and more.
Now, getting back to the title of my article, how do you actually create a table on a confluence page? Simply use the create content endpoint and the 'Send web request' action in JSM automation.
'Send web request' action allows you to use the Atlassian (or other) API, in the case of creating a Confluence page, you use the Content endpoint, and using custom data in the body request you can specify a title, choose a space, and even where in page hierarchy your new page should go and the body.
Here we come to creating a table in a page that is populated with data provided by your previous automation steps, in my example below I am listing the key, name, and the date of update of my assets.
When creating content in Confluence you can use several representation types, and when you want to populate data it is best to use "representation":"wiki", this will allow you to use wiki markup to create a table as shown below.
{
"id": null,
"type": "page",
"title": "Changed Assets- Updated{{now.convertToTimeZone("Australia/Sydney").shortTime}}",
"space": { "key": "CIS" },
"ancestors": [{ "id": "xxxxxx"}],
"body":{"storage":{"value":
"||Key||Name||Updated||\n{{#lookupObjects}}|{{Tier}}|{{Name}}|{{Updated.format("dd/MM/yyyy")}}|\n{{/}}","representation":"wiki"}}
}
A quick note about Authorization headers, you need an encoded string of your_email and your_user_api_token and this is what you will put next to Basic, to get your encoded string you do the following steps:
Elelta D
1 comment