How to extract all commercial add-ons from a JIRA instance

rootUncategorized

Introduction

objects-77Today I had to update a zillion licenses of commercial add-ons in different instances. As being a lazy consultant who likes to use a command line instead of the mouse I decided to check if I could use the UPM REST API to extract the information.

 

Ingredients for this recipe are a computer capable to run unix commands, curl (which is pretty standard on most unix distributions) and jq

Script

#!/bin/bash
 
####
# extractUserAddons.sh <baseurl> <userid> <passwd>
#
BASEURL=$1
USERID=$2
PASSWD=$3
 
  
#
# use curl to retrieve all the addons from the UPM on the JIRA
# use jq to select only the addons which have properties .userInstalled and .usesLicensing
# for each result, access the UPM again to retrieve the license information
# and retrieve information using jq
#
curl -s --user $USERID:$PASSWD $BASEURL/rest/plugins/1.0/ | jq -r '.plugins | map(select(.userInstalled)) | map(select(.usesLicensing)) | .[] | (.key) ' |
while read -r line ; do
    curl -s --user $USERID:$PASSWD $BASEURL/rest/plugins/1.0/$line-key/license | jq -r '"\(.pluginKey):\(.contactEmail):\(.supportEntitlementNumber):\(.evaluation):\(.maintenanceExpiryDateString)"'
done

How to use

1. Create the script or download it here.

2. Execute the script.  Note that you need to use an account with administration access

sh extractUserLicense.sh https://jira.acme.com francis mysecret

 

Are you still using multiple issue trackers?
Check out exalate https://www.exalate.com – Exalate is an advanced issue synchronization solution which supports cross-organization issue tracking.
Its flexibility comes from the built in groovy scripting capability allowing to implement almost any type of integration.