How can I designate a repository path when creating or cloning a Jira issue with Python?

Using Python’s Jira module, how do I set a repository path and obtain the CETM id for both new and cloned issues?

from jira import JIRA

issue_details = {
    'project': {'id': 456},
    'title': 'New Ticket',
    'details': 'This is a sample issue description',
    'issue_type': 'Bug'
}

jira_client = JIRA()
created_ticket = jira_client.issue_create(fields=issue_details)

In my case I solved it by creating a custom field to store the repository path. The Jira Python library doesn’t allow you to set a physical path directly on issue creation, so what I did was modify the issue metadata to include a repository URL or path. This lets me relate the issue to a specific repository. With cloned issues I transfer the same field information so the link remains consistent. In relation to the CETM id, I ended up using a separate process to match the repository info against a known mapping table, which worked pretty well in practice.

Based on my experience, the recommended approach is to store repository paths in a custom field within Jira. When creating an issue, you can supply a custom field value (for example, customfield_XXXXX) that holds the repository path; this works similarly with cloned issues by reading and duplicating that value. It is essential to ensure the Jira configuration allows such custom fields to be added and that your mapping of repository paths to CETM ids is in place. This approach provides a flexible solution without needing to modify the core JIRA Python module functionality.