如何通过 python 获取 jira 中问题的拉取请求的状态
How to get the status of the pull request of an issue in jira via python
我无法理解如何通过 Python jira API 获取拉取请求的状态。
我经历了 https://jira.readthedocs.io/en/latest/examples.html,
并在互联网上搜索它。但是我无法 link 带有拉取请求的 jira 问题,我看到拉取请求已 linked 到 jira 问题 ID,但无法理解如何实现它。
我正在使用 python 3.7
from jira import JIRA
issue = auth_jira.issue('XYZ-000')
pull_request = issue.id.pullrequest
我收到这个错误:
AttributeError: 'str' object has no attribute 'pullrequest'
我不确定如何在 jira 中访问 pullrequest 数据。
任何线索都会有所帮助。
我对 jira-API 的另一个 python 包装器做了类似的事情:atlassian-python-api。
看看它是否适用于您的情况:
from atlassian import Jira
from pprint import pprint
import json
jira = Jira(
url='https://your.jira.url',
username=user,
password=pwd)
issue = jira.get_issue(issue_key)
# get the custom field ref of the "Development" field (I don't know if it's always the same):
dev_field_string = issue["fields"]["customfield_13900"]
# the value of this field is a huge string containing a json, that we must parse ourselves:
json_str = dev_field_string.split("devSummaryJson=")[1][:-1]
# we load it with the json module (this ensures json is converted as dict, i.e. 'true' is interpreted as 'True'...)
devSummaryJson = json.loads(json_str)
# the value of interest are under cachedValue/summary:
dev_field_dic = devSummaryJson["cachedValue"]["summary"]
pprint(dev_field_dic)
# you can now access the status of your pull requests (actually only the last one):
print(dev_field_dic['pullrequest']['overall']['state'])
我无法理解如何通过 Python jira API 获取拉取请求的状态。 我经历了 https://jira.readthedocs.io/en/latest/examples.html, 并在互联网上搜索它。但是我无法 link 带有拉取请求的 jira 问题,我看到拉取请求已 linked 到 jira 问题 ID,但无法理解如何实现它。
我正在使用 python 3.7
from jira import JIRA
issue = auth_jira.issue('XYZ-000')
pull_request = issue.id.pullrequest
我收到这个错误:
AttributeError: 'str' object has no attribute 'pullrequest'
我不确定如何在 jira 中访问 pullrequest 数据。 任何线索都会有所帮助。
我对 jira-API 的另一个 python 包装器做了类似的事情:atlassian-python-api。
看看它是否适用于您的情况:
from atlassian import Jira
from pprint import pprint
import json
jira = Jira(
url='https://your.jira.url',
username=user,
password=pwd)
issue = jira.get_issue(issue_key)
# get the custom field ref of the "Development" field (I don't know if it's always the same):
dev_field_string = issue["fields"]["customfield_13900"]
# the value of this field is a huge string containing a json, that we must parse ourselves:
json_str = dev_field_string.split("devSummaryJson=")[1][:-1]
# we load it with the json module (this ensures json is converted as dict, i.e. 'true' is interpreted as 'True'...)
devSummaryJson = json.loads(json_str)
# the value of interest are under cachedValue/summary:
dev_field_dic = devSummaryJson["cachedValue"]["summary"]
pprint(dev_field_dic)
# you can now access the status of your pull requests (actually only the last one):
print(dev_field_dic['pullrequest']['overall']['state'])