Find what automation rules contain certain values (i.e. custom fields) using Python
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Disclaimer
Atlassian does not support this code below, which is provided "AS IS". The goal of this article is to provide a piece of code that illustrates one way to achieve the desired goal.
Feedback provided at the bottom of the page is appreciated, but won't be handled as support.
Summary
The Python script on this page searches across a JSON from the automation rule export. If the inserted value is present in your JSON file, it will return the position within the JSON and the automation rule name and state (enabled/disabled).
Environment
Jira Cloud
This script requires Python 3 to be installed.
Usage
Export all your automation rules to JSON following this article.
Ensure the script and the JSON file are in the same folder structure.
Run the script. You’ll be prompted with the value to search for and the JSON file name (remember the .json file extension).
The results will be shown in the console.
import json
def find_value(json_obj, value, path="", parent_name=None, parent_state=None):
if isinstance(json_obj, dict):
if "name" in json_obj and "state" in json_obj:
parent_name = json_obj["name"]
parent_state = json_obj["state"]
for key, val in json_obj.items():
new_path = f"{path}.{key}" if path else key
if isinstance(val, list) or isinstance(val, dict):
find_value(val, value, new_path, parent_name, parent_state)
elif isinstance(val, str) and value in val:
print(f"Found '{value}' at {new_path}")
print(f"Name: {parent_name}")
print(f"State: {parent_state}")
elif isinstance(json_obj, list):
for i, item in enumerate(json_obj):
new_path = f"{path}[{i}]"
find_value(item, value, new_path, parent_name, parent_state)
# Manually input the value to search for
search_value = input("Enter the value to search for: ")
# Manually input the JSON file name
json_file_name = input("Enter the JSON file name: ")
print(f"Searching for '{search_value}' in the JSON {json_file_name}")
# Load JSON data from a file
with open(json_file_name) as json_file:
data = json.load(json_file)
find_value(data, search_value)