Missed Team ’24? Catch up on announcements here.

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

How to establish a connection to Jira Asset Management via Python for Automation ?

Parvin Rao Mageswararao
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 21, 2023

In my Asset Management feature, I am planning to create an Automation using Python. These are the details of the goal: 

1. In my Asset Management System, there are couple Object Schemas. If click any of those schemas, there is Schema Tree, and in this Schema Tree, there is this section called "Users". 

2. In this "User" section, I can select any Users, and there is a custom attribute that was created and it is called "JiraUser". The goal is, to validate the email address of the user whether the user can be found in the Asset. If the user is found, then automatically update the custom attribute field "JiraUser" with the name of the user that is found. 

I have not found a solution to tackle this situation, therefore seeking help to put me in the right path to achieve this goal. This is an example python script that I have created ( could be your reference if there is something to be chnaged):

Screenshot 2023-11-21 at 11.51.17.pngScreenshot 2023-11-21 at 11.52.08.png

Not sure Python automation for Jira Asset Management is possible or not, but any help will be very much appreicated. Thanks!

1 answer

0 votes
Rudy Holtkamp
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 21, 2023

Hi @Parvin Rao Mageswararao ,

You could use the atlassian library: https://atlassian-python-api.readthedocs.io/index.html

Which also includes JSM api: https://atlassian-python-api.readthedocs.io/service_desk.html

If you want to query assets, you could use the assets.py from my github repo.

Parvin Rao Mageswararao
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 29, 2023

Hi @Rudy Holtkamp

 

Just have another question to clarify -> the assets.py from your github repo is a script in general to connect to the assets section, amd I right ? Since I am specifically targetting the "JiraUser" attribute in the asset management of "Users", how can I achieve this with the asset.py script from your repo ?

Thanks for your time and feeback, appreciate it.

 

Thanks,

Parvin

Rudy Holtkamp
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 29, 2023

Hi @Parvin Rao Mageswararao ,

Yes, you can connect to Assets in Jira, e.g get all User objects and get all atributes of each object. Here a little example of printing your users names and the jiraUser attributes. Note that you need to change the credentials and maybe the attribute names.

from assets import assetsConnect

sitename = "https://mysite.atlassian.net"
username = "myusername@mycompany.com"
apiToken = "S3cR3t"

# Connect to assets
myAssets = assetsConnect(siteName, username, apiToken)

allUserObjects = myAssets.getObjects('objectType = User')

for userObject in allUserObjects:
   data = myAssets.getObjectData(userObject)
   print(f"{data.get('Name')} - {data.get('jiraUser')}")

Good luck,

Rudy

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events