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

Basic Jira Software Reports at Go using APIs

Hi All,

In this article, I will showcase how easy it is for us to extract the data from APIs available in Atlassian Cloud / Data Center to quickly prepare the report for small use cases or to understand any other needs apart from the default reports that Jira provides.

With Jira Software Cloud APIs we will be able to query data related to Backlog, Boards, Epic, Sprints, Development Information, Builds, and Deployments

One such requirement we had was to Identify the Project Managers on board which consisted of several parallel sprints.

We had the board ID to list all the sprints in the board with this API along with pagination.

Once we had the sprint details, project manager's details were present in issues and we had to get all the issues in each sprint with this API

It was all about implementing logic once the data was queried for project managers and CSV was prepared with sprint and project manager's details.

The gist of the Script we used

#! /usr/bin/bash

rm sprintdets.csv > /dev/null 2>&1
rm pmsdata.csv > /dev/null 2>&1

export token=
export email=
export domain=

read -p 'Enter boardId: ' boardId

echo "collecting Sprint Details"

scount=0
hasData=true

while [ $hasData ]; do
sprintDets=$(curl -s --request GET --url "https://${domain}/rest/agile/1.0/board/${boardId}/sprint?startAt=${scount}" -u "${email}:${token}" --header "Accept: application/json" | jq -r '.values | .[] | [.self, .id, .state, .name, .startDate, .endDate, .completeDate] | @csv' | tr -d '"')
curl -s --request GET --url "https://${domain}/rest/agile/1.0/board/${boardId}/sprint?startAt=${scount}" -u "${email}:${token}" --header "Accept: application/json" | jq -r '.values | .[] | [.self, .id, .state, .name, .startDate, .endDate, .completeDate] | @csv' | tr -d '"' >> sprintdets.csv
if [ -z "$sprintDets" ]; then
hasData=false
break
fi
scount=$(expr $scount + 50)
done

count=1

echo "Collecting Project Manger Details for the Sprints ..."
while read line || [ -n "$line" ]
do
line=$(echo "$line" | sed -e 's/\r//g' | awk -F "," '{print $2}')
sprintId=$(echo $line | awk -F "," '{print $1}')
PM=$(curl -s --request GET --url "https://${domain}/rest/agile/1.0/board/${boardId}/sprint/${sprintId}/issue" -u "${email}:${token}" --header "Accept: application/json" | jq -r '.issues | .[].fields.customfield_10238 | .[] | [.emailAddress] | @csv' | tr -d '"' | sed -e 's/\r//g') #, .displayName
eval "arr=($PM)"
sorted_unique_ids=($(printf "%s\n" "${arr[@]}" | sort -u))
sed -i "${count}s $ ,$PM " sprintdets.csv
count=$(expr $count + 1)
done < "sprintdets.csv"

I hope this article will help you understand the importance of APIs available in the Atlassian Platform and how we can leverage the same to prepare the report

Do comment if you ran into scenarios where you might have prepared data with APIs

Thanks,
Pramodh

TAGS
AUG Leaders

Atlassian Community Events