One of the daunting things to do during a Cloud Migration from another Cloud Instance is usually the attachments. How do I transfer my attachments from one Jira instance to another? Well the simple answer would be, to use the Jira REST API, but how do you actually achieve this across multiple projects?
And here's where jiraone comes in, which is a REST API implementation of Jira and it helps solves problems like this one. All you simply need to do is download the library from pip as it's written in python.
pip install jiraone
Then you can be able to access all the methods, functions and classes available on it.
To give you an example of transferring attachments from one instance to another, all you need to do is
Firstly: Download a file report of the attachment structure into a flatten state, which contains the name of the file, the attachment url, the issue key where these files are located.
from jiraone import LOGIN, PROJECT user = "email" password = "token" link = "https://sourceinstance.atlassian.net" LOGIN(user=user, password=password, url=link) if __name__ == '__main__': # the output of the file would be absolute to the directory where this python file is being executed from # you can use any valid jql query jql = "project%20in%20(COM%2C%20PYT)%20order%20by%20created%20DESC" PROJECT.get_attachments_on_projects(query=jql)
Use a valid JQL to output the required project in order to get a csv file of the required data structure. Once this call completes, you will get a result output in csv format.
Secondly: Use the data structure that you got, to transfer the attachment into a target instance. Please take note that the Project must be created first on the target instance with the same corresponding issue keys and you must have the needed permissions on the project. That way the attachments are uploaded to the right issues on the target instance.
from jiraone import LOGIN, PROJECT user = "email" password = "token" link = "https://targetinstance.atlassian.net" LOGIN(user=user, password=password, url=link) if __name__ == '__main__': # the output of the file would be absolute to the directory where this # afterwards, you can use the below method to move attachments across instances without downloading it PROJECT.move_attachments_across_instances()
If you're using your own file structure, let's say a csv file. you need to identify the index of the attachment. For this, 3 keyword args are used. key=0, attach=1, and file=2 -> all requires an integer value which correspond to the index of the csv column length.
PROJECT.move_attachments_across_instances(attach_file="new.csv", key=0, attach=1, file=2)
With the above, you can easily move attachments from one Jira cloud instances to another, without downloading the attachments to your local device.
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events