我在下面的代码中读取了修订版本名称:
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
目标是从发行版中获取版本的发布日期,因为我将通过迭代来阅读项目的所有发行版。
根据此question中给出的答案,下面将获取发布日期:
i = jira.version(v.id, expand="ReleaseDate")
i.releaseDate
如何通过JIRA库使用问题详细信息获取发布日期?
注意:我不想通过REST API读取
谢谢!
答案 0 :(得分:1)
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}')
另一种选择是创建发布地图:
# 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']