Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to show project status based on number of issues

Rahul Banerjee December 12, 2018

We use JIRA cloud in BT.

Based on the number of issues in a project, I want to show assign a colored status / label in Confluence page. How do I do it ?

 

E.g. If no of issues with project "XYZ" is greater than 5, I want to have a status / label with a RED indicator on top of a confluence page

1 answer

0 votes
Diego
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 13, 2018

Hello there Rahul!
Currently, Confluence Cloud does not have a native method or macro to achieve this result. However, some REST calls can be used to perform this change.

The first step would be to create a page with a status macro and also the Jira issues macro with only one issue from the desired project. With the status macro, we will be able to control the color of it later.

After creating the page, it is time to GET the page content via REST:

REST API - GET content

This will allow us to get two sets of data, the project key from the issue macro and also the status macro data. The numbers and dash (-) should be removed from the string so we can use the key only:

<p><ac:structured-macro ac:name="jira" ac:schema-version="1" ac:macro-id="6f3f1181-9671-410c-90c4-a754f37523a2"><ac:parameter ac:name="server">JIRA</ac:parameter><ac:parameter ac:name="serverId">9de8af3e-0937-3d4b-8e79-933a2124cd43</ac:parameter><ac:parameter ac:name="key">WAG-11</ac:parameter></ac:structured-macro></p>

The value we need is under the ac:name="key" parameter.

Then, we need to check the number of issues for this specific project:

REST Client - get all issues of a project

The reply from Sayeed Ahmed is actually the one we are looking into right now. Using the key found under the issue macro we will be able to know how many issues the project has.

Lastly, we need to update the page content we got earlier to reflect the changes, based on the number of issues returned:

REST API - PUT content

For this, you will need to change two parts of the status macro, the ac:name="title" parameter and also ac:name="colour" parameter:

<p><ac:structured-macro ac:name="status" ac:schema-version="1" ac:macro-id="ecd9b86f-ac08-43b4-b1d5-800900b291f1"><ac:parameter ac:name="colour">Red</ac:parameter><ac:parameter ac:name="title">DONE</ac:parameter></ac:structured-macro></p>

This change will be based of on the arbitrary set of rules you created. Your code for this script need to have this "hardcoded" or to fetch this list of rules from somewhere else.
The reason that all these steps should be scripted is to avoid executing those calls manually after a given time interval. You can create this script using python, for example.

Let us know if this helps out your objective!

Rahul Banerjee December 14, 2018

Thanks Diego for coming back on this.

I'm not a developer rather a super user in my company and trying to build a utility which shows project RAG which should automatically update its color based on issue number.

I'm going through the above recommendation step by step.

Could you pls tell me where can I invoke the REST API on my confluence page.

My current position is both macros are added - I've added a status and one-issue from a project.

Sandeep Srinivasan August 29, 2019

where you able to do this?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events