The script retrieves up to 250 Confluence spaces, excluding archived, collaboration, and personal spaces. It fetches user and group permissions, counts unique users (skipping app accounts), and maps spaces to user counts. Data is sorted by user count and displayed in a sortable HTML table with space keys, names, user counts, and icons for clarity.
## [STEP 1] Get information
## skip archived
## skip collaboration, knowledge_base, and personal
## limit up to 250 space
## and add icon for better representation
#set ( $parameters = "status=current&type=global&limit=250&include-icon=true" )
## request spaces
#set ( $spaces = $ConfluenceManager.get("/wiki/api/v2/spaces?${parameters}").results )
#set ( $spaceMap = {})
#foreach ( $space in $spaces )
#set ( $permissions = $ConfluenceManager.get("/wiki/api/v2/spaces/${space.id}/permissions").results)
#set ( $users = {} )
#foreach ( $permission in $permissions )
#set ( $id = $permission.principal.id )
#if ( $permission.principal.type == "user" )
#set($dontOutput = $users.put($id, null) )
#elseif( $permission.principal.type == "group" )
#set ( $members = $ConfluenceManager.get("/wiki/rest/api/group/${id}/membersByGroupId").results)
#foreach ( $member in $members )
## Skip app accoutns. Only personal accounts will be counted
#if ( $member.accountType == "atlassian" )
#set($dontOutput = $users.put($member.accountId, null) )
#end
#end
#end
#end
#set ($usersSize = $users.size())
$!spaceMap.put($space, $usersSize)
#end
## [STEP 2] Represent in a table
<table class="aui aui-table-sortable">
<thead>
<tr>
<th class="aui-table-column-unsortable" style="width: 15px"></th>
<th>Space key</th>
<th>Space name</th>
<th>User count</th>
</tr>
</thead>
<tbody>
#foreach ( $space in $SortTool.sort( $spaceMap.entrySet(),"value:desc"))
#set($icon = $StringUtils.remove($space.key.icon.path, "/wiki"))
<tr>
<td><img src="$baseUrl$icon" width="15"></td>
<td><a href="$baseUrl/${space.key.id}/settings/permissions/groups">$space.key.key</a></td>
<td>$space.key.name</td>
<td><aui-badge>$space.value</aui-badge></td>
</tr>
#end
</tbody>
</table>
Perform text searches within pages, blog posts, and attachments.
Retrieve and display labels from a specified space
Display a custom list of recently updated content
Shows all attachments from the current space in a table view
Display Confluence users filtered by their email addresses.
Perform customized searches based on labels, content types, and other parameters.
Generate a list of all the content created by a current user by default or a specified user across your Confluence site.
Displays a list of pages in specific space with certain title or label
Macro for generating ID in base32 format
Macro that will show a "Delete me" message only for editors (in the Page Edit mode)