Python Jira:通过版本名称获取版本发布日期

Python Jira: Get version release date by version name

我在下面的代码中读取修复版本名称:

from jira import JIRA

jira_options = {'server': 'URL'}
jira = JIRA(basic_auth=('username', 'pwd'), options = {'server': 'username'})
fix_version = getparsedstring(issue.fields.fixVersions) #since fix Versions is not readable version name, using getparsedstring custom function to get readable string

Objective 是从问题中获取版本的发布日期,因为我将通过迭代阅读项目的所有问题。

根据此 中给出的答案,下面将检索发布日期:

i = jira.version(v.id, expand="ReleaseDate")
i.releaseDate

如何通过 JIRA 库使用问题详细信息获取发布日期?

注意:我不想通过REST阅读它API

提前致谢!

直接从问题中获取发布日期信息

issue = jira.issue('PRJ-1234')

# iterate through all fixVersions of the current issue
for fixVersion in issue.fields.fixVersions:
    # print fixVersion Name and respective Release Date
    print(f'{fixVersion.name} has the release date: {fixVersion.releaseDate}')

从字典中的映射 table 获取发布日期信息

另一种选择是创建发布映射:

# create dictionary with release name as key and release date as value
def createReleaseVersionMap(jira, project):
    versions = jira.project_versions(project)

    # Make a map from version name -> version release date
    for version in versions:
        try:
            prjVersionList[version.name] = version.releaseDate

        # if no release date is set for this version,
        # do something else, e.g., use the name as value instead of the date
        except AttributeError:
            prjVersionList[version.name] = version.name

    return prjVersionList

然后只需在您的代码中使用字典来检索相应的发布日期:

my_release_map = createReleaseVersionMap(jira, 'PRJ')
release_date_I_need = my_release_map['Release Name']