Problem:
The JIRA users do not have visibility to all the projects available in the JIRA instance and they do not know who to contact in case they need access to a specific project.Requirement:
Publish the JIRA project details with the Project admins list who can be contacted for access requests. It should be automated to be refreshed at least once a day.Solution:
Below is the shell script to extract the JIRA Project name, KEY and the Project admin list and displays in a text file. The script can be scheduled to run through a Jenkins job and result can be published in Confluence.curl -u username:password -X GET -H "Content-Type: application/json" http://URL/rest/api/2/project > projectList.json
ProjectsSize=`jq '.[] | length' projectList.json | wc -w`
ProjectAdminRoleId=10104 #Give the specific Role id for project admins in your organization. For the default "Administrator" role id will be 10002
echo -e "Project|KEY|ProjectAdmins" > List.txt
for (( i=0; i<$ProjectsSize; i++ ))
do
tkey=`jq .[$i].key projectList.json`
pkey=`echo $tkey | cut -d '"' -f 2`
curl -u username:password -X GET -H "Content-Type: application/json" http://URL/rest/api/2/project/$pkey/role/$ProjectAdminRoleId > ProjectRole.json
UserSize=`jq '.actors | length' ProjectRole.json`
ProjectAdminList=
for (( j=0; j<$UserSize; j++ ))
do
ProjectAdminList=$ProjectAdminList,`jq .actors[$j].name ProjectRole.json | cut -d '"' -f 2`
done
echo -e "`jq .[$i].name projectList.json | cut -d '"' -f 2`|`jq .[$i].key projectList.json | cut -d '"' -f 2`|`echo $ProjectAdminList | cut -c 2-`" >> List.txt
done
I have used shell scripting, curl+REST API for data extraction and jq for json parsing. You can download jq from https://stedolan.github.io/jq/
No comments:
Post a Comment