Jira Python SDK

时间:Nov. 15, 2022 分类:

目录:

细节参考官方文档

Demo

创建client

from jira import JIRA

jira_server_url = 'https://jira.whysdomain.com/'
api_token = 'MjI2NTc4NzY54dd805abac88c3a5fb99785aa8537cj4'

jiraClient = JIRA(jira_server_url, token_auth=api_token)

拉取issue列表

project='WHY'

issue_list = jiraClient.search_issues('project=%s' % project)
responce_issue_list = []
for issue in issue_list:
    print(issue.raw)

更新issue

issue_id="WHY-5"

issue = jiraClient.issue(issue_id)
print(issue.__dict__)


project = "WHY"
issuetype = "software"
summary = "new test"

jiraClient.create_issue({
    'project': {
        'key': project
    },
    'issuetype': {
        'id': '10200'
    }, # 问题类型
    'summary': summary, # 问题主题
    'customfield_10111': 24,
    'customfield_10302': '2022-12-05',
    'customfield_10301': '2022-12-07',
    'customfield_10414': [
        {'key': 'ZIYUAN-2'}
    ],
})