Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×I was working on a script to automate the license count for JIRA Software (Server), also send an email everyday about the count of licenses.
Hope this script helps someone looking for a solution to count jira licenses
I have used basic Python requests module for this. Tweak the code for your own use.
#Package for REST API CALL and json formatting
import requests
import json
#Packages for Email
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders
headers = { 'Accept': '*/*',}
url= 'https://jira.example.com/rest/plugins/applications/1.0/installed/jira-software'
r=requests.get(url=url,headers=headers,auth=("username","password"),verify=False)
print(r.status_code)
data=json.loads(r.text)
activeUsers = data['accessDetails']['activeUserCount']
#print("There are currently %d counted towards JIRA Software License" % (activeUsers))licensedUsers = data['accessDetails']['licensedUserCount']
remainingLicenses= licensedUsers - activeUsers
#print("There are %d licenses left" % (remainingLicenses))
#Send Email
recepients=['user1@example.com']
fromaddr="user2@example.com"
msg=MIMEMultipart()
msg['From']=fromaddr
msg['To']=", ".join(recepients)
msg['Subject']="JIRA License Information"
body="There are currently" + " " +str(activeUsers)+ " "+ "accounts counted towards JIRA Software License [2000 User License]"
msg.attach(MIMEText(body,'plain'))
server=smtplib.SMTP('smtp.example.com',25)
text=msg.as_string()
server.sendmail(fromaddr,recepients,text)
server.quit()
Ref: https://stackoverflow.com/questions/24077314/how-to-send-an-email-with-style-in-python3
Email Screenshot
Hope this helps getting started.
Thank You
Chander Inguva
Hey Krishna,
Please try setting the URL to Jira Cloud, unfortunately i do not have a cloud instance to check it.
I believe it should work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This doesn't seem to work anymore. The url is no longer valid. Anyone found a different approach?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Still works for Server
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Chander,
I haven't tried this script yet but I'm whiling to do it right now and would like to thank you even before actually trying it out.
Thank's for sharing this!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This api doesn't work now.
Any other solution.?
Thanks,
Irfan Ansari
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register Now
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.