Publish a Jira Project into Confluence

Since the Jira project configuration can become quite complex it is advised to make use of the builtin macro template rendering feature of the app.

This breaks the templates into smaller and often re-usable pieces resulting in better maintainability. For example the Issue Type Screen Schemes contain Screens as well as there are Workflow Transitions also containing Screens – so using a macro template for rendering Screens make code duplication superfluous.

Rendering a Jira Project

Examples:

Example of a Master Template

jira-project-overview-detailed-workflows.vm
<table>
<tr>
<th>Project</th><th>IssueTypeScreenScheme</th><th>IssueType</th><th>Screen</th><th>Tab</th><th>Field</th><th>FieldID</th><th>FieldType</th>
</tr>
#set ( $issueTypeScreenScheme = ${helper.getIssueTypeScreenScheme()} )
#set ( $screenSchemes = ${issueTypeScreenScheme.getEntities()} )
#foreach ( $screenScheme in $screenSchemes )
#set ( $issueType = $!{screenScheme.getIssueType().getName()} )
#set( $extraContext = {} )
#if ( $issueType )
#set( $extraContext.issueTypeName = $issueType )
#else
#set( $extraContext.issueTypeName = "Default (All Unassigned Issue Types)" )
#end
#set( $extraContext.screenSchemeName = $!{screenScheme.getFieldScreenScheme().getName()} )
#set( $extraContext.fieldScrenSchemeItems = $!{screenScheme.getFieldScreenScheme().getFieldScreenSchemeItems()} )
#foreach ( $fieldScrenSchemeItem in $extraContext.fieldScrenSchemeItems )
#set ( $text = ${fieldScrenSchemeItem.getIssueOperationName()} )
#set ( $screen = $!{fieldScrenSchemeItem.getFieldScreen()} )
#set ( $tabs = $screen.tabs )
#foreach ( $tab in $tabs )
#set ( $items = ${tab.getFieldScreenLayoutItems()} )
#foreach ( $item in $items )
#set ( $customfield = false )
#set ( $field = ${item.getOrderableField()} )
#set ( $customfield = ${helper.getCustomFieldObject($!field.id)} )
<tr>
#if ( $customfield )
<td>${project.key}</td><td>$!{issueTypeScreenScheme.name}</td><td>${extraContext.issueTypeName}</td><td>$!{i18n.getText($text)} $!{screen.name}</td><td>$!{tab.name}</td><td>$field.name</td><td>$field.id</td><td>$!{customfield.getCustomFieldType().getName()}</td>
#else
<td>${project.key}</td><td>$!{issueTypeScreenScheme.name}</td><td>${extraContext.issueTypeName}</td><td>$!{i18n.getText($text)} $!{screen.name}</td><td>$!{tab.name}</td><td>$field.name</td><td>$field.id</td><td></td>
#end
</tr>
#end
#end
#end
#end
</table>
holle@cat-pc-050:~/git/project-configuration-publisher/src/main/resources/default_templates> cat jira-project-overview-detailed-workflows.vm
<ac:layout>
        <ac:layout-section ac:type="two_equal">
                <ac:layout-cell>
                        <p>
                                <ac:structured-macro ac:name="toc" ac:schema-version="1" ac:macro-id="${helper.getUUID()}" />
                        </p>
                        <hr />
                </ac:layout-cell>
                <ac:layout-cell>
                        <table>
                                <tbody>
                                        <tr>
                                                <th>Project Name</th>
                                                <th>Project Description</th>
                                                <th>Key</th>
                                                <th>Type</th>
                                                <th>Lead</th>
                                                <th>Category</th>
                                                <th>URL</th>
                                        </tr>
                                        <tr>
                                                <td><a href="${helper.getProjectUrl()}">$project.name</a></td>
                                                <td>$!project.description</td>
                                                <td><a href="${helper.getProjectUrl()}">$project.key</a></td>
                                                <td>$!{project.getProjectTypeKey().getKey()}</td>
                                                <td>$!{project.getLeadUserName()}</td>
                                                <td>$!{project.getProjectCategory().getName()}</td>
                                                <td><a href="$!{project.url}">$!{project.url}</a></td>
                                        </tr>
                                </tbody>
                        </table>
                </ac:layout-cell>
        </ac:layout-section>
        <ac:layout-section ac:type="two_equal">
                <ac:layout-cell>
${helper.renderMacroTemplate("macro-issue-types-list.vm", null)}
                        <hr />
${helper.renderMacroTemplate("macro-screens-with-expander.vm", null)}
                        <hr />
${helper.renderMacroTemplate("macro-field-layouts-list.vm", null)}
                        <hr />
${helper.renderMacroTemplate("macro-priorities-list.vm", null)}
                </ac:layout-cell>
                <ac:layout-cell>
${helper.renderMacroTemplate("macro-versions-table.vm", null)}
                        <hr />
${helper.renderMacroTemplate("macro-components-table.vm", null)}
                        <hr />
${helper.renderMacroTemplate("macro-roles-with-expander.vm", null)}
                        <hr />
${helper.renderMacroTemplate("macro-permissions-table.vm", null)}
                        <hr />
${helper.renderMacroTemplate("macro-notifications-table.vm", null)}
                        <hr />
${helper.renderMacroTemplate("macro-issue-security-list.vm", null)}
                </ac:layout-cell>
        </ac:layout-section>
  <ac:layout-section ac:type="single">
    <ac:layout-cell>
                        <hr />
${helper.renderMacroTemplate("macro-workflows-with-expander-detailed.vm", null)}
    </ac:layout-cell>
  </ac:layout-section>

Example of a Macro Template

macro-priorities-list.vm
<h1>Priorities</h1>
#if ( ${helper.isPrioritySchemesAvailable()} )
#set ( $priorityScheme = ${helper.getPriorityScheme()} )
#if ( $priorityScheme )
#set ( $priorities = ${helper.getPrioritiesForScheme()} )
<h2>$!priorityScheme.name</h2>
<ul>
#foreach ( $priority in $priorities )
        <li>$!priority.name</li>
#end
</ul>
#else
<ac:structured-macro ac:name="info" ac:schema-version="1" ac:macro-id="${helper.getUUID()}">
        <ac:parameter ac:name="title">Unavailable or not Configured</ac:parameter>
        <ac:rich-text-body>Scheme: Default priority scheme</ac:rich-text-body>
</ac:structured-macro>
#end
#else
<ac:structured-macro ac:name="info" ac:schema-version="1" ac:macro-id="${helper.getUUID()}">
        <ac:parameter ac:name="title">Unavailable</ac:parameter>
        <ac:rich-text-body>No priority scheme</ac:rich-text-body>
</ac:structured-macro>
#end