本文整理汇总了Python中jira.JIRA.create_version方法的典型用法代码示例。如果您正苦于以下问题:Python JIRA.create_version方法的具体用法?Python JIRA.create_version怎么用?Python JIRA.create_version使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jira.JIRA
的用法示例。
在下文中一共展示了JIRA.create_version方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Jira
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import create_version [as 别名]
class Jira(object):
"""Python-Jira API class"""
def __init__(self, args):
"""Init"""
self.jira_server = 'https://company.jira.net'
self.jira = JIRA('%s' % self.jira_server, basic_auth=(args.jira_user,args.jira_pswd))
# Arguments
self.release_name = args.release_name
self.release_date = args.release_date
self.project = args.project
self.status = args.status
self.fix_version = args.fix_version
self.tkts_resolved = args.tkts_resolved
self.verbose = args.verbose
self.issues = []
def search_issues(self):
"""Return issues searched with JQL"""
search_str = 'project = %s AND status = %s AND fixVersion = %s order by lastViewed DESC' % \
(self.project, self.status, self.fix_version)
return self.jira.search_issues(search_str)
def is_version_exist(self):
"""Check if version exist"""
# New version is in the last element of the list
version = self.jira.project_versions(self.project)[-1]
if str(version) == self.release_name:
return True
else:
return False
def create_version(self):
"""Create Jira release version"""
descrp = []
# Adding tickets summary to release description
for tkt in self.issues:
descrp.append((tkt.fields.summary).encode('UTF8'))
descrp = '. '.join(descrp)
self.jira.create_version(self.release_name,\
self.project,\
description=descrp,\
releaseDate=self.release_date,\
startDate=None,\
archived=False,\
released=True)
def tickets_resolved_log(self):
"""Create a file with resolved tickets summary"""
version = self.jira.project_versions(self.project)[-1]
release_url = '%s/projects/%s/versions/%s/tab/release-report-all-issues/' % (self.jira_server, self.project, str(version.id))
hdr_str = "======================================================\n" \
"The new Fixes or Features added in this release are:\n" \
"\n" \
"%s\n\n" % release_url
tail_str = "======================================================"
with open(self.tkts_resolved, "a") as tkts_file:
tkts_file.write(hdr_str)
for tkt in self.issues:
tkts_file.write("%s: %s \n" % (tkt.key, tkt.fields.summary))
tkts_file.write(tail_str)
def update_issue_fix_version(self):
""" Update fixVersion of tickets"""
fixVersion = []
fixVersion.append({'name': self.release_name})
for tkt in self.issues:
tkt.update(fields={'fixVersions': fixVersion})
def create_release(self):
""" Workflow to create release:
1. Search tickets for release
2. Create Jira release version
3. Update fixVersion of tickets
4. Parse tickets resolved to file for release announcment
"""
self.issues = self.search_issues()
version_exist = self.is_version_exist()
if version_exist == False:
self.create_version()
self.update_issue_fix_version()
self.tickets_resolved_log()
def command(self, args):
"""Commands for Jira release"""
if 'create_release' in args.command:
self.create_release()
#.........这里部分代码省略.........