我想创建一个问题并将其与现有的 Epic 同时链接,我想使用名称

问题描述 投票:0回答:1

使用 JIRA python API 创建问题,并使用史诗名称而不是 ID 将其与现有史诗链接。 我还想使用受让人的名称而不是使用受让人的 ID。 如果有人能回答这个问题,那就太有帮助了。

enter image description here

python jira jira-rest-api jira-plugin python-jira
1个回答
0
投票

JIRA Python API 确实支持创建和链接问题,但与其他 API 一样,它需要 ID 而不是名称。要查找ID,请使用史诗和用户名查询API以找到相应的ID。

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)
© www.soinside.com 2019 - 2024. All rights reserved.