本文整理汇总了Python中jira.JIRA.issue方法的典型用法代码示例。如果您正苦于以下问题:Python JIRA.issue方法的具体用法?Python JIRA.issue怎么用?Python JIRA.issue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jira.JIRA
的用法示例。
在下文中一共展示了JIRA.issue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import issue [as 别名]
def main(repo, project):
jira = JIRA(JIRA_URL, basic_auth=[JIRA_USERNAME, JIRA_PASSWORD])
print("Connection to JIRA successfully established.")
print("Fetching list of matching issues...")
# Get issue list for all the issues that match given project
issue_list = []
for year in range(JIRA_YEAR_START, JIRA_YEAR_END + 1):
jira_filter = JIRA_FILTER_TEMP.format(project=project, start=year, end=year+1)
issue_list += jira.search_issues(jira_filter, maxResults=5000)
# Sort issue list
sorted_issue_list = list(sorted(
issue_list,
key=lambda i: int(i.key.split('-')[1])
))
print(f"Fetching milestones...")
milestone_map = generate_milestone_map(repo, sorted_issue_list)
print(f"The script will process {len(sorted_issue_list)} matching issues now.")
issue = jira.issue(sorted_issue_list[0].key)
for issue_key in [i.key for i in sorted_issue_list]:
issue = jira.issue(issue_key)
data, comments = generate_issue_data(issue, milestone_map)
comments.insert(0, generate_meta_comment(issue))
download_attachments(issue)
create_issue(repo, data, comments)
time.sleep(REQUEST_SLEEP)
示例2: JiraHelper
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import issue [as 别名]
class JiraHelper(object):
def __init__(self, host, user="", password=""):
self.host = host
self.user = user
self.password = password
try:
if user != "" and password != "":
self.jira = JIRA(host, basic_auth=(user, password))
else:
self.jira = JIRA(host)
except JIRAError as e:
printErrorMsg('Error connecting to %s. Check if username and password are correct.' % (self.host))
printJiraErrorAndExit(e)
def getSummary(self, issue):
"""
Gets the summary for the given ticket.
"""
issueData = self.jira.issue(issue)
return issueData.fields.summary
def getIssues(self, issues):
"""
Gets the issues from Jira with the given issue numbers.
"""
result = []
for issue in issues:
result.append(self.jira.issue(issue))
return result
示例3: update_jira
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import issue [as 别名]
def update_jira(username, password):
"""Update time logs in Jira
Current implementation uses basic authentication,
future version will have better auth. For simplicity
the toggl log should have issue number as timelog
description.
*username* to use to connect to Jira
*password* for Jira authentication
"""
url = CONFIG.get('jira')['url']
jira = JIRA(
options={'server': url},
basic_auth=(username, password))
time_logs = toggl.Connect('jira')
get_logs = time_logs.get_time_logs()
for each_log in get_logs:
issue_id = each_log.get('description')
try:
issue = jira.issue(issue_id)
except JIRAError:
logging.warning('Failed to find issue-id {0}'.format(issue_id))
continue
# Compute time in hours and round to two decimal places
time_in_hours = round(each_log['duration']/(60*60), 2)
jira.add_worklog(issue, time_in_hours, comment='Updated using Jira API')
示例4: comments
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import issue [as 别名]
def comments(task):
repo = Repo(os.getcwd())
jr = JIRA({'server': JIRA_URL}, basic_auth=(JIRA_USER, JIRA_PASS))
issue = jr.issue(task or repo.head.ref.name)
for comment in issue.fields.comment.comments:
click.echo('-----------------------------------------------------------')
click.echo(click.style(comment.author.displayName + ': \n', fg='green'))
click.echo('\r' + comment.body)
示例5: JiraHamsterListener
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import issue [as 别名]
class JiraHamsterListener(HamsterListener):
short_name = 'jira'
config_values = [
('server_url', lambda: raw_input('Root url to your jira server [f.e. "http://jira.example.org"]\n')),
('username', lambda: raw_input('Your jira user name\n')),
('password', lambda: raw_input('Your jira password\n')),
('auto_start', lambda: raw_input('Automatically start the issue when you start the task in hamster? [y/n]\n'))
]
issue_from_title = re.compile('([A-Z][A-Z0-9]+-[0-9]+)')
# noinspection PyBroadException
def prepare(self):
server_url = self.config.get(self.short_name, 'server_url')
username = self.config.get(self.short_name, 'username')
password = self.config.get(self.short_name, 'password')
logger.info('Connecting as "%s" to "%s"', username, server_url)
self.jira = JIRA(server_url, basic_auth=(username, password))
try:
self.jira.projects()
except:
logger.exception('Can not connect to JIRA, please check ~/.hamster-bridge.cfg')
def __issue_from_fact(self, fact):
"""
Get the issue name from a fact
:param fact: the fact to search the issue in
"""
fields = [fact.activity] + fact.tags
logger.debug('Searching ticket in: %r', fields)
for field in fields:
for possible_issue in self.issue_from_title.findall(field):
logger.debug('Lookup issue for activity "%s"', possible_issue)
try:
self.jira.issue(possible_issue)
logger.debug('Found existing issue "%s" in "%s"', possible_issue, field)
return possible_issue
except JIRAError, e:
if e.text == 'Issue Does Not Exist':
logger.warning('Tried issue "%s", but does not exist. ', possible_issue)
else:
logger.exception('Error communicating with Jira')
示例6: delete_issue
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import issue [as 别名]
def delete_issue(request, find):
j_issue = JIRA_Issue.objects.get(finding=find)
jira_conf = find.jira_conf()
jira = JIRA(server=jira_conf.url,
basic_auth=(jira_conf.username,
jira_conf.password))
issue = jira.issue(j_issue.jira_id)
issue.delete()
示例7: updateIssues
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import issue [as 别名]
def updateIssues(issuelist, NEXTorDOTX, description):
numExistingIssues = len(issuelist) if not issuelist == None else 0
if numExistingIssues > 0 :
if debug: print "[DEBUG] Move " + str(numExistingIssues) + " " + description
jira = JIRA(options={'server':jiraserver}, basic_auth=(jirauser, jirapwd))
cnt = 0
for s in issuelist :
key = components.getText(components.findChildNodeByName(s, 'key').childNodes)
issue = jira.issue(key)
cnt += 1
doThisJIRA = True
whichLabelSkipped = ""
for label in issue.fields.labels:
for skipLabel in skipLabels:
if label == skipLabel.strip():
whichLabelSkipped = label
doThisJIRA = False
linkURL = components.getText(components.findChildNodeByName(s, 'link').childNodes)
summary = components.getText(components.findChildNodeByName(s, 'summary').childNodes).strip()
operation = " + [" + str(cnt) + "/" + str(len(issuelist)) + "] Update " + linkURL + " : " + summary
if debug: operation = operation + " :: " + str(issue.fields.labels)
if doThisJIRA == False:
operation = " - [" + str(cnt) + "/" + str(len(issuelist)) + "] -Skip- " + linkURL + " (" + whichLabelSkipped + ") : " + summary
print operation
else:
if options.autoApplyChanges or options.dryrun:
print operation
yesno = ""
else:
yesno = raw_input(operation + " ? [y/N] ")
if options.autoApplyChanges or yesno.capitalize() in ["Y"]:
# move issue to next fixversion
if components.findChildNodeByName(s, 'project').attributes["key"].value == "JBIDE": # JBIDE or JBDS
fixversion = version_jbt
fixversion_NEXT = version_jbt_NEXT if NEXTorDOTX else version_jbt_DOTX
else:
fixversion = version_ds
fixversion_NEXT = version_ds_NEXT if NEXTorDOTX else version_ds_DOTX
fixVersions = []
# NOTE: if there is more than one fixversion, the others will not be changed
for version in issue.fields.fixVersions:
if version.name != fixversion:
fixVersions.append({'name': version.name})
fixVersions.append({'name': fixversion_NEXT})
issue.update(fields={'fixVersions': fixVersions})
# only for NEXT, not for .x
if NEXTorDOTX:
# move issue to new sprint
jira.add_issues_to_sprint(sprintId_NEXT, [key])
jira.add_comment(key, "[checkUnresolvedIssues.py] Slip to fixversion = *" + fixversion_NEXT + "* and sprint = *" + sprint_NEXT + "*")
else:
jira.add_comment(key, "[checkUnresolvedIssues.py] Slip to fixversion = *" + fixversion_NEXT + "*")
示例8: get_jira_summary
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import issue [as 别名]
def get_jira_summary(server, username, password, ticketId):
try:
jira = JIRA(server=server, basic_auth=(username, password), options={'verify':False})
issue = jira.issue(ticketId, fields='summary')
return issue.fields.summary
except JIRAError, e:
return "JIRA error: " + e.text
示例9: get_jira_details
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import issue [as 别名]
def get_jira_details(repo_history_list):
output_file = open(repo_info['filename'] + '_' + since + '_' + until + '.csv', 'w')
headings = ['Issue', 'Project', 'Summary', 'Status', 'Type', 'Components', 'Reporter',
'Created', 'Updated', 'Resolved', 'Epic', 'Fix Versions', 'PM Notes Internal', 'PM Notes External']
output_file.write(','.join(headings))
output_file.write('\n')
print('Getting JIRA details for issues...')
jira = JIRA(options, basic_auth=('noninteractive', 'etopup123'))
for jira_from_repo in repo_history_list:
if jira_from_repo == 'REVERT':
continue
try:
issue = jira.issue(jira_from_repo, fields='summary,status,issuetype,components,created,updated,'
'resolutiondate,reporter,fixVersions,customfield_10008,'
'customfield_10600,customfield_11200,project')
except Exception as e:
print('Problem obtaining info about issue=' + jira_from_repo, str(e))
output_file.write(jira_from_repo + ',Unknown,Unknown JIRA!,,,,,,,,,,,')
output_file.write('\n')
continue
summary = issue.fields.summary.replace(',', ' ')
status = issue.fields.status.name
issuetype = issue.fields.issuetype.name
components = []
for component in issue.fields.components:
components.append(component.name)
all_components = ';'.join(components)
created = parse(issue.fields.created).date().strftime("%Y-%m-%d")
updated = parse(issue.fields.updated).date().strftime("%Y-%m-%d")
resolved = ''
if issue.fields.resolutiondate:
resolved = parse(issue.fields.resolutiondate).date().strftime("%Y-%m-%d")
reporter = issue.fields.reporter.displayName
versions = []
for version in issue.fields.fixVersions:
versions.append(version.name)
all_versions = ';'.join(versions)
epic = ''
if issue.fields.customfield_10008:
epic = issue.fields.customfield_10008
pm_internal = ''
if issue.fields.customfield_10600:
pm_internal = issue.fields.customfield_10600.replace(',', ' ')
pm_internal = pm_internal.replace('\r\n', '|')
pm_external = ''
if issue.fields.customfield_11200:
pm_external = issue.fields.customfield_11200.replace(',', ' ')
pm_external = pm_external.replace('\r\n', '|')
project_name = issue.fields.project.name
try:
issue_items = [jira_from_repo, project_name, summary, status, issuetype, all_components, reporter,
created, updated, resolved, epic, all_versions, pm_internal, pm_external]
output_file.write(','.join(issue_items))
output_file.write('\n')
except Exception as e:
print('JIRA field problem for issue=' + jira_from_repo, str(e))
示例10: update_epic
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import issue [as 别名]
def update_epic(eng, push_to_jira):
engagement = eng
prod = Product.objects.get(engagement=engagement)
jpkey = JIRA_PKey.objects.get(product=prod)
jira_conf = jpkey.conf
if jpkey.enable_engagement_epic_mapping and push_to_jira:
jira = JIRA(server=jira_conf.url, basic_auth=(jira_conf.username, jira_conf.password))
j_issue = JIRA_Issue.objects.get(engagement=eng)
issue = jira.issue(j_issue.jira_id)
issue.update(summary=eng.name, description=eng.name)
示例11: update_jira_story
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import issue [as 别名]
def update_jira_story(story_id, transition_id, comment=None, **kwargs):
try:
jira = JIRA("https://thezebra.atlassian.net", basic_auth=(os.environ['username'], os.environ['password']))
issue = jira.issue(story_id)
allowed_transitions = {t['id'] for t in jira.transitions(issue)}
if str(transition_id) not in allowed_transitions:
app.logger.warn("Story %s cannot transition to %s" % (story_id, transition_id))
else:
jira.transition_issue(issue, transition_id)
if comment:
jira.add_comment(issue, comment)
except Exception as ex:
app.logger.error(ex)
示例12: add_jira_comment
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import issue [as 别名]
def add_jira_comment(jira_id, comment):
if not settings.CASELINK_JIRA['ENABLE']:
return False
user = settings.CASELINK_JIRA['USER']
password = settings.CASELINK_JIRA['PASSWORD']
server = settings.CASELINK_JIRA['SERVER']
basic_auth = (user, password)
options = {
'server': server,
'verify': False,
}
jira = JIRA(options, basic_auth=basic_auth)
jira.add_comment(jira.issue(id=jira_id), comment)
return True
示例13: build_message
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import issue [as 别名]
def build_message(self, link):
msg = self.quip(link)
try:
jira = JIRA(self._conf['JIRA_HOST'],
basic_auth=(self._conf['JIRA_LOGIN'],
self._conf['JIRA_PASSWORD']))
issue = jira.issue(ticket)
msg += '>>> %s' % self._escape(issue.fields.summary)
except Exception as ex:
if self._log:
self._log.error('JIRA: %s' % (ex))
pass
return msg
示例14: jira_command
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import issue [as 别名]
def jira_command(args):
channel = args['channel_name']
if channel == 'directmessage':
# Channel name is "directmessage" for all direct messages, so we have
# to use the channel ID to keep them separate.
channel = 'dm:%s' % args['channel_id']
issue_keys = jira_key_re.findall(args['text'])
if not issue_keys:
return Response()
log.info('Message from %s in #%s contained JIRA issue key(s): %s',
args['user_name'], channel, ', '.join(issue_keys))
# Login to JIRA
authinfo = (
current_app.config['JIRA_USERNAME'],
current_app.config['JIRA_PASSWORD'],
)
jira_url = current_app.config['JIRA_URL']
options = {'check_update': False}
jira = JIRA(jira_url, basic_auth=authinfo, options=options)
# Retrieve issue(s)
attachments = []
for issue_key in issue_keys:
try:
last_mention = get_last_mention(channel, issue_key)
if last_mention:
log.debug('%s last mentioned in #%s at %s', issue_key, channel,
last_mention)
blackout = current_app.config['JIRA_ID_BLACKOUT_PERIOD']
if datetime.now() <= last_mention + blackout:
continue
issue = jira.issue(issue_key)
attachments.append(format_attachment(issue))
except JIRAError as e:
if e.status_code == 404:
log.warning('%s does not exist', issue_key)
else:
log.error('Error looking up %s: %s', issue_key, e.text)
if not attachments:
return Response()
return jsonify({
'response_type': 'in_channel',
'attachments': attachments,
})
示例15: JiraWrapper
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import issue [as 别名]
class JiraWrapper(object):
def __init__(self, server, user, password, timeout=5.0):
self.server = server
self.auth = (user, password)
self.timeout = timeout
options = {'server': server}
self.jira = JIRA(basic_auth=(user, password), options=options)
def get_ticket(self, issue_id):
try:
return self.jira.issue(issue_id)
except Exception as e:
print(e)
return None