Create an issue using the JIRA python API and link it with an existing Epic using the epic name and not the ID. I also want to use the name for assignee rather than using the id of the assignee. It would be super helpful if anyone could answer this.
Asked
Active
Viewed 60 times
1
-
Hi, welcome to Stackoverflow! Please read [ask]. Share the code as text, not as an image, whenever possible, please. – Christian Jun 22 '23 at 22:40
-
Please provide enough code so others can better understand or reproduce the problem. – Community Jun 23 '23 at 15:34
1 Answers
0
The Python JIRA API does support creating issues and linking issues, but like other APIs, it often requires issue IDs rather than names. You can use names but you need to query the API to first find the corresponding epic and user name IDs.
from jira import JIRA
jira = JIRA('https://your-jira-url', basic_auth=('username', 'password'))
# ID of an epic by its name
epics = jira.search_issues('issuetype=Epic AND summary~"Your Epic Name"')
# first epic as example
epic = epics[0]
# ID of a user by their name
user = jira.search_assignable_users_for_projects('Your Username', 'Your Project Key')
# first user as example
assignee = user[0].name
issue_dict = {
'project': {'key': 'Your Project Key'},
'summary': 'New issue from jira-python',
'description': 'Look into this one',
'issuetype': {'name': 'Task'},
'assignee': {'name': assignee},
}
new_issue = jira.create_issue(issue_dict)
jira.create_issue_link('Relates', new_issue, epic)

Christian
- 4,902
- 4
- 24
- 42