Thursday, November 26, 2015

JIRA Script to list all project names with the corresponding project administrator

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/

Friday, November 20, 2015

About this blog...

Hi Reader

As a technical specialist of Software Tools and Processes, my work is to find and deploy right tools for the software projects and support them to achieve the Continuous Delivery flow.

As days go, i realized that i learn a lot of new things through the challenges i face every day and would definitely be helpful to the software developers and tools experts community out there.. So here i am.. Jotting down what i think will he helpful to people like me :)

Hope its helpful to the you who read this now!









And..... You are welcome ;)