如何使用 Python API 获取 JIRA 票证的创建和更新状态?
How to fetch created and updated status of JIRA ticket with Python API?
我正在尝试从 JIRA 中的票证中获取 created
和 updated
值。
我可以使用以下代码段(URL 和已编辑的凭据)解决问题:
from atlassian import Jira
import pandas as pd
import time
import glob
jira = Jira(
url = "",
username = "",
password = "",
)
projects = ["PR1", "PR2", "PR3"]
FIELDS_OF_INTEREST = ["key", "fields.summary", "fields.status.name"]
timestamp = time.strftime("%Y%m%d-%H%M%S")
csv_folder = "./csvs/"
file_ending = ".csv"
for key in projects:
output = csv_folder + key + timestamp + file_ending
print(f"Currently processing: {key}")
results = jira.jql(f"project = {key}", limit = 1000, fields=["issuetype", "status", "summary"])
df = pd.json_normalize(results["issues"])
df[FIELDS_OF_INTEREST].to_csv(output, index=False)
即使没有应用 FIELDS_OF_INTEREST
,返回的对象也不包含时间戳。要获取时间戳,我需要传入 expand=changelog
。但是当我这样做时,我不再得到我正在寻找的相同结构。不过 created
和 updated
信息是可用的。
以下片段是我目前正在尝试提取时间戳的片段(URL 和已编辑的凭据):
from atlassian import Jira
import pandas as pd
import time
import glob
jira = Jira(
url = "",
username = "",
password = "",
)
projects = ["PR1", "PR2", "PR3"]
for key in projects:
issues = jira.jql(f"project= {key}", limit = 5, expand='changelog')
df = pd.json_normalize(issues)
df.to_csv("changelog.csv", index=False)
我不确定我做的是否正确。我很想知道如何提取这些数据点。
我无法在以下位置找到任何示例:https://github.com/atlassian-api/atlassian-python-api/tree/master/examples/jira 或文档。
感谢任何帮助!
您必须进行更多检查才能获得您正在寻找的实际日期和时间戳
最相关的示例可能来自 ReportGenerator。
在 JQL 中,created
被添加到 fields
列表中,并扩展了更新日志。参见 this section。
之后,在 main execution, the histories are inspected for the changes/and their dates, and emitted.
我正在尝试从 JIRA 中的票证中获取 created
和 updated
值。
我可以使用以下代码段(URL 和已编辑的凭据)解决问题:
from atlassian import Jira
import pandas as pd
import time
import glob
jira = Jira(
url = "",
username = "",
password = "",
)
projects = ["PR1", "PR2", "PR3"]
FIELDS_OF_INTEREST = ["key", "fields.summary", "fields.status.name"]
timestamp = time.strftime("%Y%m%d-%H%M%S")
csv_folder = "./csvs/"
file_ending = ".csv"
for key in projects:
output = csv_folder + key + timestamp + file_ending
print(f"Currently processing: {key}")
results = jira.jql(f"project = {key}", limit = 1000, fields=["issuetype", "status", "summary"])
df = pd.json_normalize(results["issues"])
df[FIELDS_OF_INTEREST].to_csv(output, index=False)
即使没有应用 FIELDS_OF_INTEREST
,返回的对象也不包含时间戳。要获取时间戳,我需要传入 expand=changelog
。但是当我这样做时,我不再得到我正在寻找的相同结构。不过 created
和 updated
信息是可用的。
以下片段是我目前正在尝试提取时间戳的片段(URL 和已编辑的凭据):
from atlassian import Jira
import pandas as pd
import time
import glob
jira = Jira(
url = "",
username = "",
password = "",
)
projects = ["PR1", "PR2", "PR3"]
for key in projects:
issues = jira.jql(f"project= {key}", limit = 5, expand='changelog')
df = pd.json_normalize(issues)
df.to_csv("changelog.csv", index=False)
我不确定我做的是否正确。我很想知道如何提取这些数据点。
我无法在以下位置找到任何示例:https://github.com/atlassian-api/atlassian-python-api/tree/master/examples/jira 或文档。
感谢任何帮助!
您必须进行更多检查才能获得您正在寻找的实际日期和时间戳
最相关的示例可能来自 ReportGenerator。
在 JQL 中,created
被添加到 fields
列表中,并扩展了更新日志。参见 this section。
之后,在 main execution, the histories are inspected for the changes/and their dates, and emitted.