我正在使用 Python 2.1 在 CI / CD 中作为 JIRA 创建一个问题。
代码
from jira.client import JIRA
import requests
import jira.exceptions
import re
jira_options={'server': 'https://jira.com'}
jira=JIRA(options=jira_options,basic_auth=('username','Passwd'))
print "auth success"
issue_dict = {
'project': {'id': 12345},
'summary': 'New issue from jira-python',
'description': 'Look into this one',
'issuetype': {'name': 'Bug'},
}
new_issue = jira.create_issue(fields=issue_dict)
但是,我收到一个错误:
Traceback (most recent call last):
File "create.py", line 10, in <module>
new_issue = jira.create_issue(fields=issue_dict)
File "/usr/lib/python2.7/site-packages/jira/client.py", line 1089, in create_issue
r = self._session.post(url, data=json.dumps(data))
File "/usr/lib/python2.7/site-packages/jira/resilientsession.py", line 154, in post
return self.__verb('POST', url, **kwargs)
File "/usr/lib/python2.7/site-packages/jira/resilientsession.py", line 147, in __verb
raise_on_error(response, verb=verb, **kwargs)
File "/usr/lib/python2.7/site-packages/jira/resilientsession.py", line 57, in raise_on_error
r.status_code, error, r.url, request=request, response=r, **kwargs)
jira.exceptions.JIRAError: JiraError HTTP 500 url: https://localhost.....
是由于jira模块安装不正确还是jira服务器出现问题导致的错误。
答案 0 :(得分:0)
Python |逐步介绍如何通过python访问托管的Jira API http://thepythoncoding.blogspot.com/2018/07/python-step-by-step-how-to-access.html