本文整理汇总了Python中jira.JIRA.project_versions方法的典型用法代码示例。如果您正苦于以下问题:Python JIRA.project_versions方法的具体用法?Python JIRA.project_versions怎么用?Python JIRA.project_versions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jira.JIRA
的用法示例。
在下文中一共展示了JIRA.project_versions方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GET
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import project_versions [as 别名]
def GET(self):
gl.GL_WEBINPUT = web.input()
projectname = gl.GL_WEBINPUT.product_name
productline_list = gl.GL_DB.query("select distinct version from crashinfo where appName='" + projectname + "'")
# select *, count(distinct name) from table group by name
result = []
result_g_version = []
result_jira_version = []
#jira = JIRA(server='http://127.0.0.1:1194', basic_auth=('wangyang', 'qwerty123456'))
jira = JIRA(server=jira_server, basic_auth=(user_accout, user_pass))
for name in project:
if name in projectname:
jira_name = project[name]["projectname"]
versions = jira.project_versions(jira.project(jira_name))
for item in productline_list:
item_dict = {"game_version": item.version}
result_g_version.append(item_dict)
[result_jira_version.append({"jira_version": v.name}) for v in reversed(versions)]
result.append(result_g_version)
result.append(result_jira_version)
encodedjson = json.dumps(result)
return encodedjson
示例2: TestVersions
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import project_versions [as 别名]
class TestVersions(unittest.TestCase):
def setUp(self):
self.jira = JIRA(options=dict(server=TEST_URL, verify=False), basic_auth=(TEST_USERNAME, TEST_PASSWORD))
self.purge_test_versions()
def tearDown(self):
self.purge_test_versions()
def get_version(self, name):
versions = [_ for _ in self.jira.project_versions('KB') if _.name == 'test-1']
return versions[0] if len(versions) == 1 else None
def purge_test_versions(self):
for _ in self.jira.project_versions('KB'):
if _.name.startswith('test-'):
_.delete()
def test_create_version(self):
result = CliRunner().invoke(topcli, ['version', 'create', 'KB', 'test-1', '-d', 'Some description'])
self.assertEqual(result.exit_code, 0)
def test_delete_version(self):
result = CliRunner().invoke(topcli, ['version', 'create', 'KB', 'test-1'])
self.assertEqual(result.exit_code, 0)
self.assertIsNotNone(self.get_version('test-1'))
result = CliRunner().invoke(topcli, ['version', 'delete', 'KB', 'test-1'])
self.assertEqual(result.exit_code, 0)
self.assertIsNone(self.get_version('test-1'))
def test_update_version(self):
result = CliRunner().invoke(topcli, ['version', 'create', 'KB', 'test-1', '-d', 'before'])
before = self.get_version('test-1')
self.assertEqual(before.description, 'before')
result = CliRunner().invoke(topcli, ['version', 'update', 'KB', 'test-1', '-d', 'after'])
self.assertEqual(result.exit_code, 0)
after = self.get_version('test-1')
self.assertEqual(after.description, 'after')
def test_search_version(self):
result = CliRunner().invoke(topcli, ['version', 'create', 'KB', 'test-1', '-d', 'Some description'])
result = CliRunner().invoke(topcli, ['version', 'search', 'KB'])
self.assertEqual(result.exit_code, 0)
self.assertIn('test-1', result.output)
self.assertIn('Some description', result.output)
示例3: Api
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import project_versions [as 别名]
class Api(object):
versions = None
def __init__(self):
self.j = JIRA(
server=settings.JIRA_URL,
basic_auth=(settings.JIRA_USERNAME, settings.JIRA_PASSWORD),
)
self.project = self.j.project(settings.JIRA_PROJECT)
def get_versions(self):
return self.j.project_versions(self.project)
def get_issues(self, version_name, username):
if self.versions is None:
self.versions = self.get_versions()
version = next(
(v for v in self.versions
if version_name in v.name
and '1C' not in v.name
and '1С' not in v.name
and 'WWW' not in v.name
), None
)
if version is None:
return []
else:
jql = 'project=VIP ' \
'AND resolution=Unresolved ' \
'AND fixVersion="{fixVersion}"' \
'AND assignee in ({assignee})'.format(
fixVersion=version.name,
assignee=username,
)
return self.j.search_issues(jql)
示例4: __init__
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import project_versions [as 别名]
class JiraProject:
"""
Client in charge to retrieve all issues and comments
for a given JIRA project
"""
def __init__(self, jira_url, project_key):
self.jira_url = jira_url
self.jira_client = JIRA(
options={'server': self.jira_url, 'verify': False},
validate=False)
self.project_key = project_key
def get_comments(self, issue):
return self.jira_client.issue(issue.key, expand='comments')
def get_project_versions(self):
return self.jira_client.project_versions(self.project_key)
@staticmethod
def get_attachments(issue):
try:
return issue.fields.attachment
except AttributeError:
return None
@staticmethod
def get_assignee(issue):
try:
return issue.fields.assignee.name
except AttributeError:
return None
@staticmethod
def get_creation_datetime(issue):
return issue.fields.created
@staticmethod
def get_fix_version(issue):
try:
fix_versions = issue.fields.fixVersions
if len(fix_versions) > 0:
return fix_versions[0].name
else:
return None
except AttributeError:
return None
@staticmethod
def get_priority(issue):
try:
return issue.fields.priority.name
except AttributeError:
return None
@staticmethod
def get_resolution(issue):
if issue.fields.resolution is not None:
return issue.fields.resolution.name
else:
return None
@staticmethod
def get_title(issue):
return issue.fields.summary
@staticmethod
def get_type(issue):
return issue.fields.issuetype.name
@staticmethod
def is_closed(issue):
return issue.fields.resolution is not None
def get_issues(self):
start_index = 0
max_nb_results = 100
result = []
# while start_index < max_nb_results:
while True:
issues = self.jira_client.search_issues(
'project=' + self.project_key,
startAt=start_index,
maxResults=max_nb_results)
result.extend(issues)
if len(issues) == 0 or len(issues) < max_nb_results:
break
else:
start_index += max_nb_results
return sorted(result, key=lambda issue: int(
issue.key[issue.key.index('-') + 1:]))
def get_attachment_information(self):
start_index = 0
#.........这里部分代码省略.........
示例5: Jira
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import project_versions [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()
#.........这里部分代码省略.........