TFS4JIRA Self-Hosted | How to migrate third-party add-ons custom fields from Jira to Azure DevOps

There are custom fields unsupported by TFS4JIRA that might be necessary to migrate for keeping all Jira ticket information available in work items.

A solution for this could be to transfer these fields into a Jira comment to migrate it to ADO later. This can be achieved by running a script that puts these field values via API.

 Instructions

This Python3 script uses Jira API 7.6.

  1. Download and install python3, VS Code, and Postman.

  2. Modify the script below adjusting:

    1. Project key

    2. Instance URL

    3. Jira custom fields

    4. Barer Code (generated with Postman)

  3. Run the script using the command python3 <your-file>.py

import requests import json import math step = 4 #indicate the project key project_key = "TES2" field_names = [ "Sprint","customfield_1","customfield_2","customfield_3","customfield_4" ] url = "http://10.211.55.20:8080/rest/api/2/" # API call parameters headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer ODA2NzQ0NjMzNTE2Ovu7xmtkHpEzhSavvs3UiOcKK5Dm', 'Cookie': 'JSESSIONID=08F2583976D6EDAE06E1E119C0438F86; atlassian.xsrf.token=B7E8-XD6F-XHNM-P8E8_fd74df2a99c92ebe9feee7f8462b099d7bd96ad8_lin' } payload = json.dumps({ "jql": "project = " + project_key, "startAt": 0, "maxResults": step, "fields": [ "summary", "status", "assignee" ] }) response = requests.request("POST", url + "search" , headers=headers, data=payload) total = json.loads(response.text)["total"] total_iter = math.ceil(total/step) print(total) for i in range(total_iter): payload = json.dumps({ "jql": "project = " + project_key, "startAt": i * step, "maxResults": step, "fields": [ "summary", "customfield_10101", "customfield_10402", "customfield_10403", "customfield_10404", "customfield_10405" ] }) response_jql = requests.request("POST", url + "search" , headers=headers, data=payload) #Jira System field Sprint issues = json.loads(response_jql.text)["issues"] for issue in issues: field_values = [] issue_key = issue["key"] if issue["fields"]["customfield_10101"]: sprint_text = issue["fields"]["customfield_10101"][0] pos_1 = sprint_text.find('name=') pos_2 = sprint_text.find(',',pos_1,len(sprint_text)) sprint_name = sprint_text[pos_1+5:pos_2] field_values.append(sprint_name) print(sprint_name) #Field type single line text if issue["fields"]["customfield_10402"]: cf_1_value = issue["fields"]["customfield_10402"] print("customfield_1: " + cf_1_value) field_values.append(cf_1_value) #Field type select (single choice) if issue["fields"]["customfield_10403"]: cf_2_value = issue["fields"]["customfield_10403"]["value"] print("customfield_2: " + cf_2_value) field_values.append(cf_2_value) #Field type select Multiple Users if issue["fields"]["customfield_10404"]: cf_3 = issue["fields"]["customfield_10404"] cf_3_values = "" for item in cf_3: cf_3_values += item["displayName"] + ", " cf_3_values = cf_3_values[0:len(cf_3_values)-2] print("customfield_3: " + cf_3_values) field_values.append(cf_3_values) #Field type select Multiple Fields if issue["fields"]["customfield_10405"]: cf_4 = issue["fields"]["customfield_10405"] cf_4_values = "" for item in cf_4: cf_4_values += item["value"] + ", " cf_4_values = cf_4_values[0:len(cf_4_values)-2] print("customfield_4: " + cf_4_values) field_values.append(cf_4_values) print(i,issue_key) body_text = "" for i in range(len(field_values)): body_text += field_names[i]+ ": " + field_values[i] + "\n" body_text = body_text[0:len(body_text)-1] payload = json.dumps({ "body": "Legacy data: \n" + body_text }) #print(body_text) print(payload) response = requests.request("POST", url+"issue/"+issue_key+"/comment", headers=headers, data=payload) print(response) print("===========")

There might be some differences regarding the Jira API version.

The script can be adapted according to the third-party add-ons custom fields

The script in this article can be used as a reference. Creating or editing specific scripts for customers is beyond the scope of the TFS4JIRA Support.