Efficient management of service catalog data is crucial for organizations seeking to optimize their operations. Jira Service Management is a powerful tool for managing service requests and incidents, but exporting service catalog data can sometimes be a cumbersome process. Fortunately, I’ve developed a script that simplifies this task, allowing you to export all your service catalog information from Jira Service Management to an Excel file effortlessly.
Why Export Your Service Catalog?
Exporting your service catalog from Jira Service Management to Excel offers several benefits:
- Data Backup: Creating regular backups of your service catalog ensures that you have a copy of all your critical information in case of system failures or data loss.
- Data Analysis: Excel provides powerful tools for data analysis, visualization, and reporting. By exporting your service catalog, you can gain insights into your service offerings and performance.
- Documentation: Having a structured Excel file of your service catalog can serve as documentation for compliance, audits, or for sharing information with stakeholders who may not have access to Jira.
- Customization: You can customize the Excel file to suit your specific needs, such as adding additional columns for tracking or reporting purposes.
The Export Script
I’ve created a Python script that automates the process of exporting your service catalog from Jira Service Management to an Excel file. Here’s a brief overview of how it works:
Prerequisites:
Before using the script, make sure you have the following:
- Python installed on your system.
- The
requestslibrary installed, which can be done usingpip install requests. - The openpyxl library installed, which can be done using
pip install openpyxl. - API access to your Jira Service Management instance.
Using the Script:
- Authentication: Provide your Jira Service Management credentials and API token in the script.
- Configuration: Customize the script to specify the Jira instance, project, and any filters you want to apply.
- Execution: Run the script. It will connect to Jira, fetch the service catalog data, and format it into an Excel file.
import requests
from requests.auth import HTTPBasicAuth
from openpyxl import Workbook
import logging
import os
# Set up logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s: %(message)s')
PROJECT_START = 0
REQUEST_TYPE_START = 0
cloud = {
"username" : "<email>",
"token" : "<token",
"base_URL" : "https://<domain>.atlassian.net"
}
BASE_URL = cloud['base_URL']
# Create a new Excel workbook and select the active worksheet
wb = Workbook()
ws = wb.active
ws.title = 'Service Catalog'
# Define column headers
headers = ["Project Id", "Project Name", "Project Key", "Request Type",
"Request Type Description", "Field ID", "Field Name",
"Field Description", "Mandatory?", "Visible?"]
ws.append(headers)
def fetch_service_catalog():
project_start = PROJECT_START
while True:
# Fetch projects
project_response = requests.get(
f'{BASE_URL}/rest/servicedeskapi/servicedesk?start={project_start}',
auth=HTTPBasicAuth(cloud['username'], cloud['token']),
headers={"Accept": "application/json"}
)
if project_response.status_code != 200:
logging.error("Failed to fetch projects")
break
json_projects = project_response.json()
for json_project in json_projects["values"]:
request_type_start = REQUEST_TYPE_START
while True:
# Fetch request types for the project
request_type_response = requests.get(
f'{BASE_URL}/rest/servicedeskapi/servicedesk/{json_project["id"]}/requesttype?start={request_type_start}',
auth=HTTPBasicAuth(cloud['username'], cloud['token']),
headers={"Accept": "application/json"}
)
if request_type_response.status_code != 200:
logging.error(f"Failed to fetch request types for project {json_project['id']}")
break
json_request_types = request_type_response.json()
for json_request_type in json_request_types["values"]:
# Fetch fields for each request type
fields_response = requests.get(
f'{BASE_URL}/rest/servicedeskapi/servicedesk/{json_project["id"]}/requesttype/{json_request_type["id"]}/field?expand=hiddenFields',
auth=HTTPBasicAuth(cloud['username'], cloud['token']),
headers={"Accept": "application/json"}
)
if fields_response.status_code != 200:
logging.error(f"Failed to fetch fields for request type {json_request_type['id']}")
continue
json_fields = fields_response.json()
for json_field in json_fields["requestTypeFields"]:
row = [
json_project["id"],
json_project.get("projectName", ""),
json_project.get("projectKey", ""),
json_request_type["name"],
json_request_type.get("description", ""),
json_field["fieldId"],
json_field["name"],
json_field.get("description", ""),
"Yes" if json_field["required"] else "No",
"Yes" if json_field["visible"] else "No"
]
ws.append(row)
logging.info(f"Processed Project: {json_project['id']}, Request Type: {json_request_type['name']}")
if json_request_types["isLastPage"]:
break
else:
request_type_start += 50
if json_projects["isLastPage"]:
break
else:
project_start += 50
# Fetch data and save to an Excel file
fetch_service_catalog()
wb.save(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'Service Catalog.xlsx'))
logging.info("Service catalog saved successfully.")
Output: The script will create an Excel file containing your service catalog data.
Benefits of the Script
- Time-Saving: The script automates the export process, saving you valuable time that would otherwise be spent on manual data extraction.
- Accuracy: It ensures data accuracy by directly pulling information from Jira, reducing the risk of human error.
- Customization: You can easily modify the script to adapt to changes in your Jira setup or to include additional data fields.